location.href window.open跳转问题
window.open方法容易被各大浏览器拦截
window.location.href = linkUrl 或者window.location.replace()来替代当前的url
(注)window.location.href 不兼容华为自带浏览器 window.location.replace() 没影响
另一个解决方案
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a id='links' href="#" style='display:none;'></a>
<script type="text/javascript">
var obj = document.getElementById('links');
obj.href = "http://www.baidu.com";
obj.click();
</script>
</body>
</html>
本文标题:location.href window.open跳转问题
本文链接:https://www.haomeiwen.com/subject/perjmftx.html
网友评论