Javascript - 通过单击按钮在新选项卡中打开给定的URL [英] Javascript - Open a given URL in a new tab by clicking a button
本文介绍了Javascript - 通过单击按钮在新选项卡中打开给定的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个重定向到给定网址的按钮,并在新标签页中打开。如何做到这一点?
I would like to have a button that redirects to a given URL and opens in a new tab. How can this be done?
推荐答案
使用此:
<input type="button" value="button name" onclick="window.open('http://www.website.com/page')" />
为我工作,它将打开一个实际的新弹出窗口而不是新的完整浏览器或标签。您还可以向其添加变量以阻止它显示特定的浏览器特征,如下所示:
Worked for me and it will open an actual new 'popup' window rather than a new full browser or tab. You can also add variables to it to stop it from showing specific browser traits as follows:
onclick="window.open(this.href,'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no'); return false;"
这篇关于Javascript - 通过单击按钮在新选项卡中打开给定的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文