如何在JavaScript的新窗口中打开URL?

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

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-open-a-url-in-a-new-window-in-javascript/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值