js报错:window.location.href is not a function是由于写法问题以及浏览器不兼容导致的,具体解决方法如下:

错误js写法:

window.location.href("http://www.codesou.cn/");

正确js写法:

window.location.href = "http://www.codesou.cn/";

上面的正确js写法可以兼容绝大部分浏览器,但是在某些版本的firefox浏览器下仍然可能报错,解决办法是采用下面的写法:

window.location = "http://www.codesou.cn/";

相关文章:$(…).XXX is not a function的解决办法