问题:
js中用window.location.href("url")实现页面的跳转,IE中可以正常使用,但是Firefox却提示window.location is not a function。
解决方案:
google以后将代码改为window.location="url" 程序正常执行。
简言之:
下面的格式可以在IE中正常执行,但是不能在Firefox和Chrome中执行:
window.location.href("http://stackoverflow.com");
下面的格式可以以上三个浏览器中全部正常执行:
window.location.href = "http://stackoverflow.com";
此外,在搜索中发现,window.location.href="url"在Firefox中也会遇到无法正常执行的原因,推荐的方法是window.location="url". 因为,有些浏览器中window.location.href是只读属性。
window.location.href在本页面打开链接
window.open新建窗口打开链接