我在一个HTML项目上工作,我不知道如何在没有JavaScript的新选项卡中打开链接。

我已经知道<a href="http://www.WEBSITE_NAME.com"></a>在同一选项卡中打开链接。有什么办法能让它在一个新的盒子里打开吗?


当前回答

你可以这样做:

<a href="http://www.WEBSITE_NAME.com" target="_blank" rel="noopener noreferrer">Open</a>

原来是:

<a href="http://www.WEBSITE_NAME.com"></a>

也可以查看MDN上的以下url,了解更多关于安全和隐私的信息:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Security_and_privacy

它又有一个链接到一篇名为Target="_blank"的好文章——有史以来最被低估的漏洞:

https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/

其他回答

你可以这样做:

<a href="http://www.WEBSITE_NAME.com" target="_blank" rel="noopener noreferrer">Open</a>

原来是:

<a href="http://www.WEBSITE_NAME.com"></a>

也可以查看MDN上的以下url,了解更多关于安全和隐私的信息:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Security_and_privacy

它又有一个链接到一篇名为Target="_blank"的好文章——有史以来最被低估的漏洞:

https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/

在React的情况下,如果有人想在一个新标签中打开链接。请使用from react-router-dom,因为<a href="/path"></a>刷新整个页面,即使您的页面只改变了新路由上的一些文本或图像。 链接的使用请参考这里

Target ="_blank"属性将完成这项工作。 只是不要忘记添加rel="noopener noreferrer"来解决潜在的漏洞。更多信息请访问:https://dev.to/ben/the-targetblank-vulnerability-by-example

<a href="https://www.google.com/" target="_blank" rel="noopener noreferrer">Searcher</a>

在新选项卡中打开链接的简单方法是在链接中添加一个目标属性,其值等于“_blanl”,如下所示:

< a href = " http://www.WEBSITE_NAME.com " target = "平等" > < / >

使用目标=“平等”:

<a href="http://www.example.com/" target="_blank" rel="noopener noreferrer">This will open in a new window!</a>