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?
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?
Share Improve this question asked Feb 22, 2013 at 8:41 Notsogood13Notsogood13 1091 gold badge4 silver badges11 bronze badges 13 | Show 8 more comments6 Answers
Reset to default 15late 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.
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
.
Try this
window.open("https://www.google.com/", "_blank");
This code is working fine for me. If this doesn't work then make sure you should not declare a variable or function named with "open". (I have faced this issue once.)
I do not know why but below change works for me in your fiddle.
Change
var link = $(this).attr('data-link');
window.open(link);
If you tried it in chrome console and found it not working, try it as a script preloaded with the page. It worked in my case.
If you have a local variable named "window" or "open" then the function "window.open()" would not work anymore.
open
in the previous code? – Teemu Commented Feb 22, 2013 at 8:44