user653522
user653522

Reputation:

Internet Explorer 7 + alert() doesn't work

Can some of you please tell me why a simple alert() isn't working using jQuery 1.4 in Internet Explorer 7, when it's working in all other browsers? It's been driving me crazy now for the last half an hour..!

$(document).ready(function(){
    alert("wtf?");
})

This simple example doesn't show an alert in IE7. See for yourself at http://jsfiddle.net/8HQdp/.

Upvotes: 4

Views: 15955

Answers (4)

Christian
Christian

Reputation: 28144

  1. Ensure your console doesn't show any errors and correct them if there are any.
  2. Be sure you didn't disable browser prompts on IE
  3. Try using window.alert() - it's possible (though improbable) that another alert() is conflicting with window's.
  4. If you have console support, try console.log(alert); and see what it says. It should be something like:

    function alert() {
        [native code]
    }
    

Upvotes: 4

Ernestas Stankevičius
Ernestas Stankevičius

Reputation: 2493

Try using window not document.

Upvotes: -1

Simon
Simon

Reputation: 2830

It works in IE 7 mode in IE 8 form me. Takes a while but it does trigger.

I noticed that there is a semi colon missing from the ready function. should be...

$(document).ready(function(){

}); //missing semicolon here

Also, try using the shortcut for the DOM ready function...

$(function(){
   // code here
});

Upvotes: 0

Moe Sweet
Moe Sweet

Reputation: 3721

I'm using IE8 but with IE7 mode, the alert on http://jsfiddle.net/8HQdp/ still triggers. Try changing $ to jQuery and host your own jquery.js.

And also try console.log('wtf') before alert so u know whether it's alert or document.ready is broken.

Upvotes: 2

Related Questions