js模拟a标签点击在新窗口打开

				这个会被浏览器拦截
				var el = document.createElement("a");
				document.body.appendChild(el);
				el.href = "http://www.baidu.com"; //url 是你得到的连接
				el.target = '_new'; //指定在新窗口打开
				el.click();
				document.body.removeChild(el);
 
 
 
 
				这个不会被拦截
				<a href="" id="alink" target="_blank" style="display: none"><span id="spanlink">test</span></a> 
				<input type="button" value="点我弹出新页面" onclick="targetClick()" /> 
				function targetClick() { 
					$("#alink").attr("href", "http://www.163.com"); 
					$("#spanlink").click(); 
					return false; 
				}

猜你喜欢

转载自blog.csdn.net/qq_36617310/article/details/78495992