Created
June 15, 2017 10:52
-
-
Save swapnilshrikhande/d22a31b63f8edbab125451c32b587cc5 to your computer and use it in GitHub Desktop.
Access parent page url from iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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