Skip to content

Instantly share code, notes, and snippets.

@EricDavies
Created May 13, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricDavies/f1104b101347419306e7 to your computer and use it in GitHub Desktop.
Save EricDavies/f1104b101347419306e7 to your computer and use it in GitHub Desktop.
getting parent url
<html>
<head>
<title> child</title>
</head>
<script type="text/javascript">
function dumpit() {
var div = document.getElementById("dumpzone");
var parentUrl;
if (parent !== window){
parentUrl = document.referrer;
}
else {
parentUrl = "not in iframe";
}
div.innerHTML = parentUrl;
}
</script>
<body onload="dumpit();">
child-above
<div id="dumpzone">Empty</div>
child-below
</body>
</html>
<html>
<head>
<title>parent </title>
</head>
<body>
parent top<br>
<iframe src="http://ssh.priologic.com:8080/child.html"></iframe>
parent bottom<br>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment