How to open a URL in a new window in JavaScript?
如何在JavaScript的新窗口中打开URL?
For example, to open a new window to browse “http://www.systutorials.com“.
例如,打开一个新窗口浏览“ http://www.systutorials.com ”。
Open the URL in a new window:
在新窗口中打开URL:
url = "http://www.systutorials.com";
window.open(url);
Some browser will open the window in a new tab depending on the configuration. If you want to force the browser to open a new window, a tip is to use code as follows.
某些浏览器会根据配置在新选项卡中打开窗口。 如果要强制浏览器打开新窗口,提示是使用代码,如下所示。
window.open(
url, "window name",
"height=200,width=200,modal=yes,alwaysRaised=yes");
(it works on most browsers while the browser may still choose to ignore it)
(它适用于大多数浏览器,而浏览器可能仍然选择忽略它)
Additionally, the “window.close()
” method can close the window.
另外,“ window.close()
”方法可以关闭窗口。
Full syntax of the “window.open()” method can be found in:
可以在以下位置找到“ window.open()”方法的完整语法:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
https://developer.mozilla.org/zh-CN/docs/Web/API/Window/open
翻译自: https://www.systutorials.com/how-to-open-a-url-in-a-new-window-in-javascript/