【问题标题】:Remove links from an iframe?从 iframe 中删除链接?
【发布时间】:2015-01-18 13:08:45
【问题描述】:

我是初学者,需要一些帮助。

我正在尝试使用 iframe 从另一个站点复制计划。我需要从 iframe 中删除链接。到目前为止我有这个:

<iframe src="www.example.php" width="750" frameborder="0" scrolling="no" style="min-height:400px; height:auto;" onload='javascript:resizeIframe(this);'></iframe>

我可以添加什么来删除网址中的链接?

提前非常感谢!

【问题讨论】:

    标签: iframe


    【解决方案1】:

    如果我正确理解您的问题,您想更改 iFrame 中的内容吗?看看这个问题:jQuery changing contents of an iFrame

    【讨论】:

    • 谢谢 Sjors。并没有真正改变内容,只是让它没有一个链接是可点击的。
    【解决方案2】:

    您无法编辑/更新从 iFrame 返回的内容,除非它位于同一域中。要访问不同域的 iFrame 内容,请应用以下解决方案。

    此解决方案的工作原理与 iFrame 相同。我创建了一个 PHP 脚本,可以从其他网站获取所有内容,最重要的是您可以轻松地将自定义 jQuery 应用于该外部内容。请参考以下脚本,该脚本可以从其他网站获取所有内容,然后您也可以应用您的自定义 jQuery/JS。此内容可以在任何地方、任何元素或任何页面内使用。

    <div id='myframe'>
    
      <?php 
       /* 
        Use below function to display final HTML inside this div
       */
    
       //Display Frame
       echo displayFrame(); 
      ?>
    
    </div>
    
    <?php
    
    /* 
      Function to display frame from another domain 
    */
    
    function displayFrame()
    {
      $webUrl = 'http://[external-web-domain.com]/';
    
      //Get HTML from the URL
      $content = file_get_contents($webUrl);
    
      //Add custom JS to returned HTML content
      $customJS = "
      <script>
    
          /* Here I am writing a sample jQuery to hide the navigation menu
             You can write your own jQuery for this content
          */
        //Hide Navigation bar
        jQuery(\".navbar.navbar-default\").hide();
    
      </script>";
    
      //Append Custom JS with HTML
      $html = $content . $customJS;
    
      //Return customized HTML
      return $html;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 2013-02-10
      • 2015-11-10
      相关资源
      最近更新 更多