1

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.

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.

How can I hide the header in all the pages? (if the site is loaded in an iframe, of course)

Community
  • 1
  • 1
  • 1
    how about loading the same js code in each page where you would like this header hiding effect to be in place? Edit: if you have a master page, you can place the code in your master page such that it is loaded on all pages that uses this master page – Ji_in_coding Jan 22 '15 at 18:18
  • @Ji_in_coding I putted it in the footer of all my pages, when I add the action to the wp_footer it adds it in the footer.php archive wich is loaded in every page :/ – Ayesha Lomaski Jan 23 '15 at 09:25
  • Try to comment out your iframe detection, simply turn off header iregardless of iframe or browser. Visit a couple pages in your browser to make sure it is working. Then test in iframe again. Maybe that can help you narrow down root of cause. – Ji_in_coding Jan 23 '15 at 11:27
  • @Ji_in_coding Thanks! Just discovered that jquery wasn't loading in other pages and that's why the code didn't worked :) – Ayesha Lomaski Jan 23 '15 at 13:21

1 Answers1

1

As Ji_in_coding said, you'll need to include (and run) that javascript code on each pages.

If you have a index.php page that uses include for all your website content, you can include the code there. if not, you'll need to include it on every page.

Math
  • 666
  • 8
  • 26