解决window.open被浏览器拦截,或手机上无反应的问题。
主要是window.open有时候会被当作广告进行拦截,网上办法有很多,大概看了一下。
延迟跳转 模拟按钮 模拟表单
今天主要发一下 简单的模拟按钮。
function openurl(url) {
//创建A标签
var a = document.createElement('a');
//给创建好的a标签赋值
a.setAttribute('href', url);
//设置css 隐藏属性
a.setAttribute('style', 'display:none');
//设置 a标签为新窗口打开
a.setAttribute('target', '_blank');
//将设置好的a标签,添加到 body 内
document.body.appendChild(a);
//模拟点击
a.click();
//移除a标签
a.parentNode.removeChild(a);
}
转载请注明出处 AE博客|墨渊 » 解决window.open被浏览器拦截的问题
发表评论