thePurpleMonkey
thePurpleMonkey

Reputation: 838

alert statement is not working

Here is my code:

alert("First");
if (!Modernizr.inputtypes.color) {
    alert("This form is optimized for a browser that supports html5. Using anything else may produce unexpected results. Use at your own risk.\n\nThis bowser doesn't appear to support html5.");
} else {
    alert("Second");
}
alert("Third");

This is run when the page is first loaded. The first alert statement works correctly. The second and third ones are not run at all. I've tried it in Chrome, Firefox, and Internet Explorer and I get the same result in all of them. Maybe Modernizr is messing something up? I don't know, I just copied and pasted the code. I've probably made a glaringly obvious mistake. (I've done it before) Thanks for your help in advance.

Upvotes: 1

Views: 256

Answers (1)

Danilo Valente
Danilo Valente

Reputation: 11342

I'd guess that Modernizr or Modernizr.inputtypes is undefined (probably because it wasn't loaded before this code), so Modernizr.inputtypes.color gives an error. Therefore, the following lines (which include the second and third alert statements) won't be executed.

Upvotes: 1

Related Questions