Html 强制导航器通过 URL 在新标签页中打开链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13643909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:09:47  来源:igfitidea点击:

Force navigator to Open Link in New Tab by URL

html

提问by Hatim

i have a request if possible, i have an interface which containts a table :

如果可能,我有一个请求,我有一个包含表的界面:

name of application   url 
XXXXXX                www.xxx.com

Problem is when I click in the url I lose my information on my current page. my question is there is a code language by Internet explorer FF chrome... provide this action open in tab this url to put in the url like the method version and the other like this about:version ==> open in new tab : this url to put in the url navigator and we get a new tab thank you for help . i try open in a new tab by tools provided by IE , but if possible provide a solution like a code entered in url to open a new tab

问题是当我点击 url 时,我会丢失当前页面上的信息。我的问题是 Internet Explorer FF chrome 有一种代码语言...提供此操作在选项卡中打开此 url 以放入方法版本之类的 url,另一个像这样 about:version ==> 在新选项卡中打开:this url 放入 url 导航器,我们会得到一个新标签,谢谢您的帮助。我尝试通过 IE 提供的工具在新选项卡中打开,但如果可能,请提供一个解决方案,例如在 url 中输入的代码以打开新选项卡

回答by Denys Séguret

If I get you, you want your link to open the page in another tab.

如果我明白了,您希望您的链接在另一个选项卡中打开页面。

You may use the targetattribute of the link like this :

您可以像这样使用链接的目标属性:

<a href="somepage.html" target=newtab>text</a>

If you want something you can type in the URL field of the browser, that is a bookmarklet,you may use this :

如果你想要一些你可以在浏览器的 URL 字段中输入的东西,bookmarklet,你可以使用这个:

javascript: window.open('http://www.dystroy.org');

In most browsers, ctrl-click a link do the same thing.

在大多数浏览器中,按住 ctrl 单击链接可以做同样的事情。

EDIT :

编辑 :

If what you can modify is only the hrefattribute of the link, you can make this href be like this :

如果你能修改的只是href链接的属性,你可以把这个href变成这样:

 <a href="javascript:window.open('http://www.dystroy.org');" target=_blank>text</a>

回答by Anna

If its a hyperlink just add a "target" to the hyperlink with its value as "_blank". Working example:

如果它是一个超链接,只需在超链接中添加一个“目标”,其值为“_blank”。工作示例:

<a id="termsLink" href="www.someLink.com" target=_blank>
                Terms and Conditions</a>

回答by René

The java script solution works great in case of shortcodes which offer you an href (or url) option but no target parameter. Here is an example with a popular callout shortcode:

在为您提供 href(或 url)选项但没有目标参数的短代码的情况下,java 脚本解决方案非常有效。这是一个带有流行标注短代码的示例:

[callout title='Your big Title' text='your small text...' button_text='CLICK ME' button link="**javascript:window.open**('http://www.dystroy.org');"]

Without the javascript, the linked page would open onto the current one.

如果没有 javascript,链接页面将打开到当前页面。

回答by BuddhiP

You don't need any code to open a link in a new tab or window. HTML already has that functionality built in.

您不需要任何代码即可在新选项卡或窗口中打开链接。HTML 已经内置了该功能。

Use an tag to show your url and use the target attribute to tell it to open in a new window.

使用标签显示您的 url,并使用 target 属性告诉它在新窗口中打开。

Example:

例子:

<a href="http://www.xxx.com" target="_blank">www.xxx.com</a>

Learn more about a tag and target attribute here

在此处了解有关标签和目标属性的更多信息