【问题标题】:how to remove or hide a div from a iframe added如何从添加的 iframe 中删除或隐藏 div
【发布时间】:2020-08-18 11:47:18
【问题描述】:

我无法从我的网站http://dubaimarketingexperts.com/index.html 的 iframe 中删除 div div to be removed

<iframe title="Dubai Free SEO Quote" 
    src="" allowtransparency="true" 
    allow="geolocation; microphone; camera" 
    allowfullscreen="true" 
    name="41015223436139" 
    id="41015223436139" 
    scrolling="no"
    style="width: 10px; min-width: 100%; display: block; overflow: hidden; border: medium none; height: 225px;" >
</iframe>

<script>
    $(document).ready(function() {
        $("#41015223436139").contents().find(".black-friday-2019").remove();
    });
</script>

感谢任何帮助

【问题讨论】:

    标签: javascript html jquery css iframe


    【解决方案1】:

    网站和 iframe 是否在同一个域下?如果是这样,请在 iframe 页面中尝试以下脚本

    if (window.self !== window.top) {
      document.querySelectorAll(".black-friday-2019").forEach(el => el.remove());
    } else {
      document.querySelectorAll(".black-friday-2019").forEach(el => el.add());
    }
    
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2012-12-20
      • 1970-01-01
      相关资源
      最近更新 更多