【问题标题】:How to hide blogger blog header when calling inside a static webpage using iframe使用 iframe 在静态网页内调用时如何隐藏博主博客标题
【发布时间】:2017-04-22 11:14:23
【问题描述】:

我们的组织有一个博客博客,现在我们正在规划网站,我们计划在其中使用 iframe 调用博客页面,但是当我们这样做时,整个博客页面都进入了,我们想要删除或隐藏博客在网站内部调用时标头,有什么办法可以做到这一点

【问题讨论】:

  • 您唯一的选择是在 Blogger 上操作模板/使用自定义模板。如果 iframe 中的内容是从不同的域加载的,您将无法对其进行操作。

标签: html iframe iframe-app


【解决方案1】:

Blogger 允许您向模板添加自定义 CSS 和 Javascript。

我基于“简单”主题对此进行了测试,没有进一步修改。转到主题 - 在您的博客设置中编辑 HTML 并在标题小部件下方的某处添加此代码(基于 this snippet):

<script type="text/javascript">
if (window.self !== window.top){
    document.getElementById("header").style.display = "None"
}
</script>

header 是 HTML 模板中定义的那个小部件的 id

<b:section class='header' id='header' ...

【讨论】:

    【解决方案2】:

    感谢各位大侠的解答,我在博客代码中使用如下解决了

    <script type="text/javascript">
       var isInIFrame = (window.location != window.parent.location);
       if(isInIFrame==true){
    
           document.getElementById('tohide').style.display = "none";
           }   
    </script>
    

    【讨论】:

      猜你喜欢
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-06
      • 1970-01-01
      • 2015-07-19
      • 2010-11-11
      相关资源
      最近更新 更多