Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: window.open is not a function

I keep getting this error on firebug -> TypeError: window.open is not a function

code:

    $(document).ready(function()
{
    $('.div').click(function()
    {
        var link = $(this).data('link');
        window.open(link);
    });
});

Isn't that function supposed to work?

like image 719
Notsogood13 Avatar asked Dec 08 '22 17:12

Notsogood13


2 Answers

late but for all other coders! if you have a global variable named "open" like "open = true;" or "var open = true" or something like that, then the function "open()" would not work anymore.

like image 91
Erhard Dinhobl Avatar answered Dec 11 '22 10:12

Erhard Dinhobl


Although it's not entirely clear from your question, the value of window.open is not read-only and can therefore be changed by other code, such as:

window.open = false;
// ...
window.open('something') // error: window.open is not a function

If you know what scripts are loaded on your page, this shouldn't be hard to do, just search for anything relating to window.open.

like image 22
Ja͢ck Avatar answered Dec 11 '22 10:12

Ja͢ck