我做了一个简单的重定向,强迫用户使用HTTPS而不是HTTP。我知道有很多方法可以缩短newUrl变量,但是事实是,这个循环在IE8中是连续的,但是在FF中是有效的。页面的其余部分甚至不加载..。但我得到了我希望的网址.有人知道为什么window.location在IE8上的操作方式不同吗?
<script language="JavaScript">
if (location.protocol = "http:") {
var newUrl = "https://";
newUrl += location.hostname;
newUrl += ":64040";
newUrl += location.pathname;
newUrl += location.search;
// redirect
window.top.location = newUrl;
}
</script>发布于 2013-10-17 17:06:07
您必须使用2=来比较字符串:
if (location.protocol == "http:") {https://stackoverflow.com/questions/19432940
复制相似问题