Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Created June 15, 2017 10:52
Show Gist options
  • Save swapnilshrikhande/d22a31b63f8edbab125451c32b587cc5 to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/d22a31b63f8edbab125451c32b587cc5 to your computer and use it in GitHub Desktop.
Access parent page url from iframe
<html>
<body>
</body>
<script>
var currentUrl = document.referrer;
document.write('currentUrl : '+ getJsonFromUrl(currentUrl).conid );
function getJsonFromUrl(query) {
var regex = /[?&]([^=#]+)=([^&#]*)/g,
url = query,
params = {},
match;
while(match = regex.exec(url)) {
params[match[1]] = match[2];
}
return params;
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment