[英]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.