Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

javascript

This is my code:

function loadOffer(id) {
    window.open("http://www.google.com.com","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?

like image 587
Dan Avatar asked Feb 01 '26 11:02

Dan


2 Answers

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.

like image 91
davin Avatar answered Feb 03 '26 00:02

davin


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"
like image 38
nrabinowitz Avatar answered Feb 03 '26 02:02

nrabinowitz