Passing parameters to an iFrame
Ok more than a little pleased with myself, since I am not a coder it was pretty cool when I saw this work.
The problem I had was that I had a form (using Eloqua but could be any form) posted in an iFrame on the site. The frame needed to autofill values (such as email address) that were passed in the query string via an email. The iframe was not passing the parameters and I couldn't use javascript in the article so I thought I was screwed.
Then I realized that if I added the javascript to the header of the skin wrapper it would work for any iframes that needed to be passed parameters via the query string, but if there were no paramters, it would just do nothing. So I added this code (from a guy on the Eloqua forum) to my header wrapper:
<script type="text/javascript">
$(document).ready(function()
{
var loc = window.location.toString(),
params = loc.split('?')[1],
iframe = document.getElementById("trackFrame");
iframe.src=iframe.src + '?' + params;
});
</script>
Then in the article I added the parameter id="trackFrame"
so that the iFrame looked like this:
<iframe id="trackFrame" src="http://my.company.com/theurl" width="300" height="500" frameborder="0"></iframe>
Eh voila when I click the link in the email my email address prepopulates on the form.