Answers:
用这个:
<input type="button" value="button name" onclick="window.open('http://www.website.com/page')" />
为我工作,它将打开一个实际的新“弹出”窗口,而不是一个新的完整浏览器或选项卡。您还可以向其添加变量,以阻止其显示特定的浏览器特征,如下所示:
onclick="window.open(this.href,'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no'); return false;"
添加target =“ _ blank”应该可以:
<a id="myLink" href="www.google.com" target="_blank">google</a>
<a>标记是适当的。应该使用样式使它看起来像一个按钮。
您可能会忘记使用JavaScript,因为浏览器控制它是否在新选项卡中打开。最好的选择是改为执行以下操作:
<form action="http://www.yoursite.com/dosomething" method="get" target="_blank">
<input name="dynamicParam1" type="text"/>
<input name="dynamicParam2" type="text" />
<input type="submit" value="submit" />
</form>
无论该target="_blank"属性是什么,客户端使用的浏览器都将始终在新选项卡中打开。
如果您只需要没有动态参数的重定向,则可以使用target="_blank"TimBüthe建议的带有属性的链接。
我的首选方法的优点是您的标记中没有嵌入JavaScript:
的CSS
a {
color: inherit;
text-decoration: none;
}
的HTML
<a href="http://example.com" target="_blank"><input type="button" value="Link-button"></a>
使用javascript在新标签页中打开
<button onclick="window.open('https://www.our-url.com')" id="myButton"
class="btn request-callback" >Explore More </button>
我只是在form标记下使用了target =“ _ blank”,它在FF和Chrome上可以正常工作,在FF和Chrome上可以在新标记中打开,而在IE中可以在新窗口中打开。
<BUTTON NAME='my_button' VALUE=sequence_no TYPE='SUBMIT' style="background-color:transparent ; border:none; color:blue;" onclick="this.form.target='_blank';return true;"><u>open new page</u></BUTTON>
此按钮看起来像URL,可以在新标签页中打开。
a标记。
使用此代码
function openBackWindow(url,popName){
var popupWindow = window.open(url,popName,'scrollbars=1,height=650,width=1050');
if($.browser.msie){
popupWindow.blur();
window.focus();
}else{
blurPopunder();
}
};
function blurPopunder() {
var winBlankPopup = window.open("about:blank");
if (winBlankPopup) {
winBlankPopup.focus();
winBlankPopup.close()
}
};
在Mozilla,IE和chrome以及低于22的版本上,IT都可以正常工作;但不适用于Opera和Safari。