My first post here! My question relates to iframes and php mostly
So… it’s impossible for PHP to check if a page was requested through an iframe. This question seems to be asked (and answered) a lot, but would it be possible to create an “iframe context” and maintain that context throughout the navigation within an iframe?
For example :
<iframe src="/my/url?location=iframe"></iframe>
we could initially check if ($_GET[‘location’] == ‘iframe’)
however, as navigation goes on, you can imagine what happens. Links are click, forms are submitted, and they don’t necessarily have ?location=iframe.
So, I’m trying to figure out how to create an initial context that begins with the url parameter above and persists within the iframe only.
Just to be clear, in my example the iframe contains pages from the same site.
Thanks for your help.
What if you set the initial URL to
/iframe/my/urlwhen it’s loaded in an iframe, and/my/urlwhen it isn’t, and either:$_SERVER['PHP_SELF']mod_rewriteto rewrite the URL so it points to the right place and has thelocation=iframeor maybe#iframetagged onto itThe first option is probably the best, although all your paths would have to relative. This means all your paths will stay within the
/iframe/path and you never need to alter your links – everything is processed for you.