Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save PardotGists/c681d4cd073f08065b1f to your computer and use it in GitHub Desktop.

Select an option

Save PardotGists/c681d4cd073f08065b1f to your computer and use it in GitHub Desktop.
Passing URL Parameters from Browser to iframe
<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>
@iiq374
Copy link
Copy Markdown

iiq374 commented Sep 5, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment