繁体   English   中英

如何不使用window.location重定向到另一个HTML页面?

[英]How to redirect to another html page without using window.location?

因此,我正在Intel XDK中开发一个应用程序,因此,如果用户没有wifi连接,我将使用下一个脚本重定向到另一个页面:

if (!navigator.onLine) {
    window.location.replace("nowifi.html");
}

在Web浏览器中可以正常工作,但是在Intel XDK中由于Window位置而无法工作(我需要添加一个插件才能使其工作),您知道另一种重定向方式吗?

您可以插入超链接标记并模拟对其的单击:

var link = document.createElement('a');
link.href = "http://google.com";
document.body.appendChild(link).click();

仅尝试位置:

if (!navigator.onLine) {
    window.location = "nowifi.html";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM