基本上我只想点击链接,打开一个新窗口。但是窗口会在新选项卡中打开。 不确定为什么
<a href="http://www.google.com" target="_blank" style="font-size: 12px;" onclick="popupwindow(this.href, 'Redirect to')"><b>Link</b></a>
JS:Fiddle link
答案 0 :(得分:3)
按照步骤: -
1. In html write return false to avoid default event default behaviour
2. From javascript return false
3. Check for popup blocker
JAVASCRIPT
function popupwindow(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (newwindow == null || typeof(newwindow)=='undefined') {
alert('Please disable your pop-up blocker and click the "Open" link again.');
}
else {
newwindow.focus();
}
return false;
}
HTML
<a href="popupex.html" onclick="return popupwindow(this.href)"
>Link to popup</a>
答案 1 :(得分:0)
不幸的是,这无法控制,完全由用户代理决定。