0

On our companies website, we have a list of products, then when you click on a product, a popup opens with the product details. Because this was a popup (in a lightbox) I created a single-productpopup.php and removed the header and footer.

The problem I have now, is that the Products are showing up in the Sitemap, and therefore search engines (and this is what we want), but when the link is clicked, the single-productpopup.php is loaded, and this doesn't have a header or footer, so the visitor has no way to continue navigating around the site.

What I'm hoping is is there a way to detect if the page is being loaded in an iframe, and so do an if statement something like if page is not in iframe show header and footer

Or is there a more practical way to do this, maybe with different php files?

Edit: After thought - or add the header and footer with display: none by default, and use javascript/jquery to change that?

0

I solved this by adding the header php code, and the setting it with display none as below:

#main-header {
  display:none;
}

Then using JQuery I added the following:

<script>
  if(self==window.top)
  {
  $( "header#main-header" ).css( "display", "inherit" );
  $( "div#mce_height" ).css( "margin-top", "100px" );
  }
</script>

This detects if it is in an iframe, and if it's not, it will show the header

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.