Created
September 25, 2015 19:52
-
-
Save PardotGists/c681d4cd073f08065b1f to your computer and use it in GitHub Desktop.
Passing URL Parameters from Browser to iframe
This file contains 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
<noscript> | |
<iframe src="PARDOT_FORM_URL" width="100%" height="500" type="text/html" frameborder="0" allowTransparency="true" style="border: 0"></iframe> | |
</noscript> | |
<script type="text/javascript"> | |
var form = 'PARDOT_FORM_URL'; | |
var params = window.location.search; | |
var thisScript = document.scripts[document.scripts.length - 1]; | |
var iframe = document.createElement('iframe'); | |
iframe.setAttribute('src', form + params); | |
iframe.setAttribute('width', '100%'); | |
iframe.setAttribute('height', 500); | |
iframe.setAttribute('type', 'text/html'); | |
iframe.setAttribute('frameborder', 0); | |
iframe.setAttribute('allowTransparency', 'true'); | |
iframe.style.border = '0'; | |
thisScript.parentElement.replaceChild(iframe, thisScript); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
document.scripts[document.scripts.length - 1] really needs to be updated to find the script by id; otherwise this will break everytime it's not the last script on the page