title: Javascript Run Function After Page Load
body: <p>I'm trying to create a small automation script in Javascript that I want to run with a site using Opera's User Script feature to define external scripts to run. I have used this feature before to run scripts I wrote with external sites, to nice effect. </p>
  
  <p>I need to wait till the page loads for the script to run, but I can't seem to get this to work. The code currently is: </p>
  
  <pre><code>if (addEventListener in document) { // use W3C standard method
      document.addEventListener('load', meerfirst(), false);
  } else { // fall back to traditional method
      document.onload = meerfirst();
  }
  
  function meerfirst(){
      nameForm = document.forms['aspnetForm'];
      nameForm.elements('ctl00$CPH1$NewQuoteView$TitlesView$DropDownListTitles').value = 'MR:TRUE:MR';
      nameForm.elements('ctl00$CPH1$NewQuoteView$TextBoxFirstName').value = 'James';
   }
  </code></pre>
  
  <p>This is my own function with the addition of the if statement found via another question here. I have also tried window.onload, but it still didn't work. </p>
  
  <p>Strangely Opera doesn't really seem to execute the script at all, as if I set a breakpoint on the if statement it never actually breaks on it. Could the site have a anti-userscript feature built-in? Or is there possible something I'm doing wrong to stop this executing? </p>