简体   繁体   English

如果我的网站位于iframe中,则我不希望标题显示在任何页面中

[英]if my site is in an iframe I don't want the header to show in any pages

I was trying the solution found in: Hide header if in iframe and when the iframe is laoded it truly works, but if I click in any link on my website the header appears, I don't want the header to be shown in ANY pages if it is in a iframe. 我正在尝试以下解决方案: 如果在iframe中对标题进行隐藏,并且在iframe修改后才真正起作用,但是如果单击网站上的任何链接,则会显示标题,我不希望该标题显示在任何页面中如果在iframe中。

for now my code is 现在我的代码是

function no_header_iframe(){ ?>
<script type="text/javascript">
    function inIframe () {
    try {
        return window.self !== window.top;
    } catch (e) {
        return true;
    }
}

if(inIframe()){
    $('nav').addClass('hidden').hide();
}
</script>
<?php } 
add_action('wp_footer', 'no_header_iframe');

since my site is in wordpress. 因为我的网站在wordpress中。

How can I hide the header in all the pages? 如何在所有页面中隐藏标题? (if the site is loaded in an iframe, of course) (当然,如果网站是在iframe中加载的)

As Ji_in_coding said, you'll need to include (and run) that javascript code on each pages. 正如Ji_in_coding所说,您需要在每个页面上包含(并运行)该javascript代码。

If you have a index.php page that uses include for all your website content, you can include the code there. 如果您有一个index.php页面,其中包含所有网站内容,则可以在其中包含代码。 if not, you'll need to include it on every page. 如果没有,则需要在每个页面上都包含它。

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

相关问题 不想在我的网站上显示 IFRAME KML 上使用的 LINK - Don't want to show LINK used on IFRAME KML the my site 我不想在 React JS 的错误页面上显示 Header 和页脚 - I don't want to show Header & Footer on Error page in React JS 我想通过使用 forEach 方法更改歌曲名称,但它没有改变,也没有显示任何错误 - i want to change songName by using forEach method but it's doesn't change and don't show any error 我不想在页面上运行JS Service Worker - JS Service Worker running on pages I don't want it to run on 我有一个简单的网站,想在鼠标悬停时更改字体大小,但此代码不起作用。为什么? - I have a simple site and want to change my font-size when the mouse is over but this code don't work.Why? 如果我不按写按钮,我想显示一个警报 - If I don't press write button, I want to show an alert Javascript显示/隐藏-我不希望它隐藏整个元素 - Javascript show/hide - I don't want it to hide the entire element 如何在javascript中调用onclick事件? 我不想在HTML页面中使用任何事件 - How do i invoke the onclick event in javascript? I don't want to use any events in my HTML page 我不希望我的表单在提交后刷新 - i don't want my form to refresh after i submit 我不希望使用javascript为我的cookie设置特定路径 - I don't want a specific path for my cookie using javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM