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
3 Answers
Reset to default 7You'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);