js打开网址,如何让在新窗口中打开

代码如下: <button style="width:300;height:90;background:transparent; margin:0px; border:0px;padding:0px;cursor:hand" onclick="window.location.href=' www.baidu.com/'"></button>

1.超链接<a href="http://www.jb51.net" title="脚本之家">Welcome</a>

等效于js代码

window.location.href="http://www.jb51.net";     //在同当前窗口中打开窗口

 

2.超链接<a href="http://www.jb51.net" title="脚本之家" target="_blank">Welcome</a>

等效于js代码

window.open("http://www.jb51.net");                 //在另外新建窗口中打开窗口

温馨提示:内容为网友见解,仅供参考
第1个回答  2015-07-05
onclick="window.open(' http://www.baidu.com ');“
href的话 需要设置target的属性为:_blank
第2个回答  2014-06-21
<button style="width:300;height:90;background:transparent; margin:0px; border:0px;padding:0px;cursor:hand" onclick="window.open(' http://www.baidu.com ');"></button>本回答被提问者采纳
相似回答