简体   繁体   English

iframe链接以打开浏览器作为新选项卡

[英]iframe link to open a browser as a new tab

I have an iframe that pops up on an HTML page. 我在HTML页面上弹出了一个iframe。 In the iframe popup there is a link. 在iframe弹出窗口中有一个链接。 When a user clicks the link I want the link to open a new tab in the main browsers and not in the iframe. 当用户点击链接时,我希望链接在主浏览器中打开新标签,而不是在iframe中打开。 I have tried adding the following 我尝试添加以下内容

<a href="http://www.google.com" target="_parent">Test</a>

all this does is open the page in the main browser (not in a new tab) therefore the user leaves the page. 所有这一切都是在主浏览器中打开页面(而不是在新选项卡中),因此用户离开页面。

Any help appreciated! 任何帮助赞赏!

Here are some values for the target attribute 以下是target属性的一些值

_blank = Loads the page into a new browser window. _blank =将页面加载到新的浏览器窗口中。

_self = Loads the page into the current window. _self =将页面加载到当前窗口中。

_parent = Loads the page into the parent _parent =将页面加载到父级中

W3C Docs here on target attribute (right at the bottom) 关于目标属性的W3C文档(位于底部)

Updated: as pointed out by @Eregrith in the comments below - you cannot make the link open in a new tab - that is controlled client side (in the browser settings) you can open it in a different window - using _blank 更新:正如@Eregrith在下面的评论中指出的那样 - 您无法在新标签中打开链接 - 即受控客户端(在浏览器设置中)您可以在另一个窗口中打开它 - 使用_blank

i know its too late to reply, but may be this will be helpful for someone, 我知道回复已太晚了,但可能会对某人有所帮助,

if you can place an iFrame to your website and do not want to be open its link to the same frame, just follow the simple steps below... 如果您可以将iFrame放置到您的网站,并且不想打开它到同一帧的链接,只需按照下面的简单步骤...

  1. create an empty div with position absolute with the relative to its outer div... 使用相对于其外部div的位置绝对创建一个空div

  2. Overlap the link button with this div, add tag and add the same link with target blank. 使用此div重叠链接按钮,添加标记并添加与目标空白相同的链接。

     <div class="your_name"> <a href="domain.com">; &nbsp; </a> </div> <style type="text/css"> .your_name { position:absolute; top: 5px; /*adjust its top and left position as required*/ left:5px; } .your_name a { width:20px; /* add height and width as required */ height:10px; display:block; } </style> 

cheers..!!! 干杯..!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM