Can I display different content based on an iframe?

OTrap

Elite Member
Joined
Jul 12, 2008
Messages
2,314
Reaction score
1,064
What I currently have is something like this:

PHP:
<?php


if ( window.self === window.top ) { ?>

<html>not in a frame</html>
<?php } else { ?>

<html>in a frame</html>

<?php } ?>

However, I'm obviously missing something, as it reacts as though it's in an iframe, no matter what.

I have to be missing something, but I'm curious as to what.
 
You 're confusing things. PHP runs on the server, there is no iframe context there - no "window" object :)

That 's on the client side (after your server has already sent the content to the browser). At that point, javascript is your scripting option.
 
Ah, much obliged, Jazz. You're the man.
 
It's javascript code. Just create HTML page and insert your code between these tags:
<script type="text/javascript">
[your_code]
</script>
 
The catch is that it can't show up in the source code. ;)
 
Fair enough. All the domains are owned by me, so I wanted to see if it was possible, but as it doesn't seem to be, that's not a problem.

Thanks for the help!
 
Back
Top