gpt4 book ai didi

Javascript重定向无限循环

转载 作者:行者123 更新时间:2023-11-28 05:05:56 25 4
gpt4 key购买 nike

Chrome 没有重定向到 Intranet 站点。 body onload 方法无限循环。如果我将目标更改为外部网站(例如 google.com),重定向就会起作用。有人可以指点一下为什么我的 Intranet 站点存在无限循环吗?

下面是我的 HTML

<!DOCTYPE HTML>
<script type="text/javascript" src="openBrowser.js"></script>
<script type="text/javascript">
function openURL(){
var targetURL="http://myintranetsite";
openBrowser(targetURL);
}
</script>

<BODY onLoad="openURL()">
<div id="loadBrowser"><h1>Opening Browser..</h1></div>
</BODY>
</HTML>

我的 JavaScript

var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(isChrome)
{
//Changes the URL to destination if the current chrome browser version is 40
if(getChromeVersion()>=40)
{
window.location=targetURL;
}
}

最佳答案

你的代码必须针对chrome版本40或更高版本进行重定向,你必须看到你还没有到达你想去的地方,导致无限重定向。这是适合您的代码

  var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(isChrome)
{
//Changes the URL to destination if the current chrome browser version is 40
if(getChromeVersion()>=40 && window.location!==targetURL)
{
window.location=targetURL;
}
}

关于Javascript重定向无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41751860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com