title: Why doesn't this Javascript work with Opera or Chrome?
body: <p>Thanks for reading.</p>
  
  <p>I have several scripts that are built similar to the following:</p>
  
  <p><strong>scriptone.js</strong></p>
  
  <pre><code>function FunctionOne(){
  
      // Do a bit of work...
  
      // Include a second javascript file, scripttwo.js
      // that contains a function called FunctionTwo.js
      var scrb = document.createElement('script');
      scrb.type = 'text/javascript';
      scrb.src = 'http://www.example.com/scripttwo.js?bunchofargs=varied';
  
      // Append it to the head.
      document.getElementsByTagName('head')[0].appendChild(scrb);
  
      // Can't run the second function directly, because it may not be loaded quite yet,
      // So use the Waiter function.
      Interval = setInterval("Waiter()", 10);
  
      // All done.
      return;
  
  }
  
  function Waiter(){
      if(window.FunctionTwo) {
          clearInterval(Interval);
          FunctionTwo();
      }
  }
  </code></pre>
  
  <p><strong>scripttwo.js</strong></p>
  
  <pre><code>function FunctionTwo(){
      document.write('something based on calling page');
  }
  </code></pre>
  
  <p>This works fine with FF and IE, but not with Opera or Chrome.  In Chrome/Opera, everything seems to work ok in script one.  However, nothing that should be happening in scripttwo.js actually happens.  It's as if scripttwo.js didn't get included.</p>
  
  <p><strong>Any ideas why this doesn't work with Opera or Chrome?</strong>  </p>
  
  <p>Perhaps I'm using something that isn't compatible, or are there security features I am not aware of?  All files are on the same domain.</p>
  
  <hr>
  
  <p><strong>Note</strong>
  Great replies - thanks so much!</p>
  
  <p>FuncionOne is just a typo here, in the actual code, I use better function names, but I changed them here for readability.  It may be the scope, though i agree with Joe White that it shouldn't be an issue.  With JavaScript (one of my weak languages), who knows?  FunctionOne is called from either the head or body of the HTML document.</p>
  
  <p>I also like the idea of adding FuncTwo to the end of script two, to avoid the timer altogether.  Cleaner, and so obvious once somebody points it out to you...</p>
  
  <p>I will update after I work on this next.</p>
  
  <p><strong>Update Again:</strong></p>
  
  <p>Hi All,</p>
  
  <p>I now have it working in FF, IE, and Chrome, but Opera seems to refuse to load any .js files at all now.  I'm thinking this is just an Opera issue of some sort (<a href="https://stackoverflow.com/questions/1053676/opera-js-file-wont-load">Opera: .js file won&#39;t load</a>), and will proceed with the other three.  Let you know how it turns out.</p>