繁体   English   中英

iframe内的打开链接iframe内的链接

[英]Open Links Inside of an iframe Outside of the iframe

我使用了类似于以下内容的iframe代码:

<iframe src="/comment_contents.php?profile_id=2850" height="100%" width="100%" style="border: none;">
</iframe>

在另一页的自举程序模式中(/profile_comments.php?profile_id=2850)。

iframe页面(/comment_contents.php?profile_id=2850)中的HTML内容如下所示:

<form method="post" action="/comment_contents.php?profile_id=2850" class="form-comment">
  <div class="form-comment-contents">
    <input type="text" name="comment" value="" class="comment-text">
    <input type="submit" value="Comment" class="comment-submit">
    <br><br>
    <a href="/view_profile.php?id=2851">
      <img src="img/profile2851.jpg" class="circle-comments" alt="Emma Watson">
    </a>
    <div class="comment-text lead">You are just awesome!</div>
    <br>
    <a href="/view_profile.php?id=2852">
      <img src="img/profile2852.jpg" class="circle-comments" alt="Bill Gates">
    </a>
    <div class="comment-text lead">You are Cool!</div>
  </div>
</form>.

您可能已经注意到有一个代码:

<a href="/view_profile.php?id=2852">...</a>

因此,当人们单击它时,iframe内的个人资料视图页面就会打开。 但是我希望链接不是在iframe中打开,而是在外部打开。 我的意思是,在网址栏中。

是否有任何JavaScript或其他工具可以在网址栏中打开链接网址(在iframe中)?

只需将target="_top"添加到该链接

<a href="/view_profile.php?id=2851" target="_top"><img src="img/profile2851.jpg" class="circle-comments" alt="Emma Watson"></a>

您是要在新标签页中而不是在同一标签页中打开链接?

你可以试试这个

a href =“ / view_profile.php?id = 2852” target =“ _ blank”> ...

我使用了target =“ _ blank”,它允许您在新标签页中打开链接。 此链接可能有帮助, https://www.w3schools.com/tags/att_a_target.asp

暂无
暂无

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

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