I have a HTML file http://mydomain.com/page1.html:
<!doctype html>
<html>
<iframe src="http://mydomain.com/page2.php"></iframe>
</html>
In page2.php, I would like to get the url of the "container page", which in this case is the string page1.html
.
Is there anyway to do so without javascript?
The browser may send the parent's URL as Referer in the HTTP request, so look at $_SERVER['HTTP_REFERER']
. That's not guaranteed though. As such, there's no 100% foolproof way. If the client doesn't supply the information in the request, there's nothing else whatsoever you can do on the server side without explicitly passing the parameter in the URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With