Home javascript js: isn't defined

js: isn’t defined

Author

Date

Category

Error only in Firefox.

ReferenceError: Vislideshow is not defined.

The code itself looks like this:

vislideshow ();
FUNCTION VISLIDESHOW () {
  $ ('. Slide5'). Delay (5000) .Fadeout (5000);
  $ ('. Slide4'). Delay (10,000) .Fadeout (5000);
  $ ('. Slide3'). Delay (15000) .Fadeout (5000);
  $ ('. Slide2'). Delay (20,000) .Fadeout (5000);
  Vislidhide ();
}
FUNCTION VISLIDHIDE () {
  $ ('. Slide2'). Delay (5000) .Fadein (5000);
  $ ('. Slide3'). Delay (15000) .Fadein (5000);
  $ ('. Slide4'). Delay (20,000) .Fadein (5000);
  $ ('. Slide5'). Delay (25000) .Fadein (5000);
  SetTimeout (VislideShow (), 10,000);
}

How to fix the error?


Answer 1, Authority 100%

either transfer, or make a $ (Document) .ready functions

$ (document) .ready (function () {
  VislideShow ();
});
FUNCTION VISLIDESHOW () {
  $ ('. Slide5'). Delay (5000) .Fadeout (5000);
  $ ('. Slide4'). Delay (10,000) .Fadeout (5000);
  $ ('. Slide3'). Delay (15000) .Fadeout (5000);
  $ ('. Slide2'). Delay (20,000) .Fadeout (5000);
  Vislidhide ();
}
FUNCTION VISLIDHIDE () {
  $ ('. Slide2'). Delay (5000) .Fadein (5000);
  $ ('. Slide3'). Delay (15000) .Fadein (5000);
  $ ('. Slide4'). Delay (20,000) .Fadein (5000);
  $ ('. Slide5'). Delay (25000) .Fadein (5000);
  SetTimeout (VislideShow (), 10,000);
}

Answer 2, Authority 100%

Announcement Functions Transfer the above call, otherwise you are trying to call a function that has not yet been announced.

function vislideshow () {
  $ ('. Slide5'). Delay (5000) .Fadeout (5000);
  $ ('. Slide4'). Delay (10,000) .Fadeout (5000);
  $ ('. Slide3'). Delay (15000) .Fadeout (5000);
  $ ('. Slide2'). Delay (20,000) .Fadeout (5000);
  Vislidhide ();
}
FUNCTION VISLIDHIDE () {
  $ ('. Slide2'). Delay (5000) .Fadein (5000);
  $ ('. Slide3'). Delay (15000) .Fadein (5000);
  $ ('. Slide4'). Delay (20,000) .Fadein (5000);
  $ ('. Slide5'). Delay (25000) .Fadein (5000);
  SetTimeout (VislideShow (), 10,000);
}
VislideShow ();

and always better execute JS after loading the entire page and resources

$ (function () {
  VislideShow ();
});

It is important to still understand the principle of compiling JS. JIT compilation


Answer 3

settimeout (vislideshow (), 10,000);

Blobes remove:

settimeout (VislideShow, 10,000);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions