字符串不是窗口位置href上的函数 [英] String is not a function on window location href
本文介绍了字符串不是窗口位置href上的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑:
$('.b').click(function(){
var link = 'www.yahoo.com';
window.location.href(link);
});
我希望它打开www.yahoo.com,但它说字符串不是函数".为什么?
I expect it to open www.yahoo.com, but it says "string is not a function". Why?
jsFiddle: http://jsfiddle.net/V9Xat/
jsFiddle: http://jsfiddle.net/V9Xat/
推荐答案
Try-
window.location.href = link;
或
window.location.assign(link);
这篇关于字符串不是窗口位置href上的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文