javascript 如何在新标签页或窗口中打开 iframe 链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18995704/
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-10-27 14:00:22  来源:igfitidea点击:

How to open iframe link in new tab or window

javascripthtmliframetabshyperlink

提问by puneetjava

I am using some iframe tags in my html page as shown below:

我在我的 html 页面中使用了一些 iframe 标签,如下所示:

   <TABLE border="0" width="900">
    <tr valign="top">
    <td width="300" ALIGN=center>
                  <iframe src='http://www.apple.com/in/'  frameborder = 0, height=250, width = 300  > </iframe><br>

    </div>
       </td>

    <td width="300" ALIGN=center>
            <div class="item_list">
            <iframe src = 'http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-137232779171598318'  frameborder = 0, height=250, width = 300 base target="_blank"  > </iframe></a><br>
            </div>
      </td>
      <td width="300" ALIGN=center>
            <div class="item_list">
            <iframe src = 'http://www.flipkart.com/affiliate/displayWidget?affrid=WRID-  137232785207215857' frameborder = 0, height=250, width = 300 > </iframe>
      <br></div>
    </td>
    </tr>
     </TABLE>

Now what i need , is to open the link which is inside in iframe to new tab or window. I have used below script regarding this, but no luck.

现在我需要的是打开 iframe 中的链接到新选项卡或窗口。我已经使用了以下脚本,但没有运气。

   <SCRIPT LANGUAGE="JavaScript">

   function goNewWin() {

    //***Get what is below onto one line***

    window.open("backbuttonnewpage.html",'TheNewpop','toolbar=1,
   location=1,directories=1,status=1,menubar=1,
    scrollbars=1,resizable=1'); 

   //***Get what is above onto one line*** 

   self.close()

      }

   </SCRIPT>   

can anyone suggest me any solution for this?

任何人都可以建议我对此有任何解决方案吗?

回答by Luke Dyte

I think you're trying to just open a new page in a new tab. If so, here is the code you need:

我认为您正在尝试在新选项卡中打开一个新页面。如果是这样,这里是您需要的代码:

<a href="WebAdress.netdom" target="_blank"><button>Open New Tab</button></a>