当前位置:首页 >> 网络编程

JS打开新窗口的2种方式

1.超链接<a href="https://www.jb51.net" title="">Welcome</a>

等效于js代码

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

 

2.超链接<a href="https://www.jb51.net" title="" target="_blank">Welcome</a>

等效于js代码

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