开发者

Internet Explorer 7 + alert() doesn't work

开发者 https://www.devze.com 2023-04-12 19:21 出处:网络
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

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/.


  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]
    }
    


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.


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
});


Try using window not document.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号