当前位置: 移动技术网 > IT编程>开发语言>JavaScript > window.open 防止浏览器拦截

window.open 防止浏览器拦截

2019年04月19日  | 移动技术网IT编程  | 我要评论
https://blog.csdn.net/sinat_37255207/article/details/89374416 网上试了很多方法 最终只有一种可以 如果 网速慢的话 接口反馈慢 会出现重定向太慢 很长时间停留在 百度页面 所以 最好 先window.open 一个固定好的 loading ...

https://blog.csdn.net/sinat_37255207/article/details/89374416

 

网上试了很多方法 最终只有一种可以 

 

var newwin = window.open('https://www.baidu.com/');
 
wxpublic().then(res=>{
 
// 重定向到目标页面
 
if(res.data.statuscode!='200'){
 
newwin.location.href ='404页面';
 
return;
 
}
 
newwin.location.href = res.data.responsecontent.url;
 
}).catch(()=>{
 
newwin.location.href ='404页面';
 
//失败重定向到404html
 
})

如果 网速慢的话 接口反馈慢  会出现重定向太慢 很长时间停留在 百度页面  所以 最好 先window.open 一个固定好的 loading html  失败的话 可以跳转404html 也可以 newwin.close 关闭对应的新弹框 

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网