title: Javascript to set value of dropdown field within Iframe
body: <p>I have a page with a petition on it.  The petition is embedded from a petition providing website.  The embedding code creates an iframe, and loads the petition inside it.</p>
  
  <p>The problem is that one of the petition values is "Country" and I am trying to change that default value to a different country after the petition has loaded within my page to make it easier for people who may sign the petition.</p>
  
  <p>I have tried adding a function to the onload of the window, but it appears that it is still too early, before the embedded petition page is loaded.  Here is the code I currently have:</p>
  
  <pre><code>&lt;script&gt;
  window.onload = function(e){ 
  var ifr = document.getElementsByTagName('iframe')[0];
  var ifrDoc = ifr.contentDocument || ifr.contentWindow.document;
  var theCountry = ifrDoc.getElementById( 'sign_country');
  var newValue = "ie"; // set to country
  theCountry.value = newValue;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Any help?... perhaps I'm using the wrong event?</p>