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?
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.
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.
如果您有一个名为“window”或“open”的局部变量,那么函数“window.open()”将不再起作用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.