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

javascript - Uncaught TypeError: Property 'open' of object [object DOMWindow] is not a function - Stack Overflow

programmeradmin1浏览0评论

This is my code:

function loadOffer(id) {
    window.open("","mywindow");
}

It's initiated onClick. However I get the following error:

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

Any ideas?

This is my code:

function loadOffer(id) {
    window.open("http://www.google..","mywindow");
}

It's initiated onClick. However I get the following error:

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

Any ideas?

Share Improve this question edited Jun 8, 2011 at 21:52 Michael Robinson 29.5k12 gold badges107 silver badges131 bronze badges asked Jun 8, 2011 at 21:49 DanDan 311 silver badge2 bronze badges 1
  • 1 Which browser are you encountering this error in? – Michael Robinson Commented Jun 8, 2011 at 21:54
Add a ment  | 

3 Answers 3

Reset to default 7

You've defined a global variable somewhere called open and it's not a function. It's overridden the normal function of window.open.

Yet another good reason to namespace our javascripts.

Under normal circumstances, window.open is a function. So you've probably changed it somewhere else in the code, most likely by defining a variable open without a var statement.

> window.open
function open() { [native code] }
> open = "test"
"test"
> window.open
"test"

found this at http://drupal/node/1003664

wrap your code in this

(function ($) {
  // All your code here
})(jQuery);
发布评论

评论列表(0)

  1. 暂无评论