最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript Alert Boxes not working in Chrome - Stack Overflow

programmeradmin1浏览0评论

This is weird, The following line of javascript:

alert("test");

gives the following error in chrome:

Uncaught TypeError: Property 'alert' of object [object DOMWindow] is not a function

It also breaks when using a prompt. Oddly it works in firefox. Any ideas?

This is weird, The following line of javascript:

alert("test");

gives the following error in chrome:

Uncaught TypeError: Property 'alert' of object [object DOMWindow] is not a function

It also breaks when using a prompt. Oddly it works in firefox. Any ideas?

Share Improve this question edited Feb 14, 2011 at 19:54 theChrisKent 15.1k3 gold badges63 silver badges62 bronze badges asked Feb 14, 2011 at 19:29 Frank ConryFrank Conry 2,7183 gold badges30 silver badges41 bronze badges 4
  • I am not able to replicate this error when placing this command alone in a document and viewing it in Chrome. Do you have any other scripts loading on the page? – Chris Baker Commented Feb 14, 2011 at 19:38
  • 3 was the popup blocker, better popup blocker for chromium. glad to be back on the right side of the sun! – Frank Conry Commented Feb 14, 2011 at 20:23
  • 1 Love the fact some many people jump down the poster's throat about being a bad developer. Show some love on VD [and hopefully not a VD.] :) End result was some other developer's poorly written plug-in that caused the bug. You can go rip that developer[s] a new one. lol – epascarello Commented Feb 14, 2011 at 20:26
  • 1 If you set a variable name to "alert" you can have this problem as well. var alert = $('<div class="alert">Nope</div>'); alert('Message'); // Error – BigToach Commented Nov 1, 2012 at 20:35
Add a comment  | 

3 Answers 3

Reset to default 32

Do you have a another pop up blocker plug-in installed on Chrome? If you do, disable/remove it and see if the error goes away.

Is your Javascript enabled in the Chrome options? Other thing is any other js library included which might change default js behaviour?

As epascarello said its because of popup blocker plugin and I faced this problem with my localhost websites and prompt method.
So i fixed it by adding my localhost url to popup blocker's whitelist: http://localhost

发布评论

评论列表(0)

  1. 暂无评论