Using document.write() to load javascript
<p>Excuse my newb question. I'm still in the beginning stages of learning javascript. I'm not sure If I can accurately describe to you guys what i'm trying to do, but i'll try.</p>

<p>Is it possible to load a javascript file onto an html page?</p>

<p>for example. Twitter gave me code for there twitter widget, and it's a javascript widget. I want to be able to display it on my page using the document.write method. Is this possible. Here is an example.</p>

<p>This is the code they gave me.</p>

<pre><code>&lt;script src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt;
&lt;script&gt;
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: '@blahblah',
  interval: 6000,
  title: 'Follow Me On Twitter',
  subject: 'blahblah',
  width: 180,
  height: 300,
  theme: {
    shell: {
      background: '#ebebeb',
      color: '#969396'
    },
    tweets: {
      background: '#ffffff',
      color: '#000000',
      links: '#bbbcbd'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
&lt;/script&gt;
</code></pre>

<p>So, is it possible that I could write this to the html page like this?</p>

<pre><code>document.write('&lt;script src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt; '
    &lt;script&gt;
    'new TWTR.Widget({
      version: 2,
      type: 'search',
      search: 'blah',
      interval: 6000,
      title: 'Follow Me On Twitter',
      subject: '@blahBlah',
      width: 180,
      height: 300,
      theme: {
        shell: {
          background: '#ebebeb',
          color: '#969396'
        },
        tweets: {
          background: '#ffffff',
          color: '#000000',
          links: '#bbbcbd'
        }
      },
      features: {
        scrollbar: false,
        loop: true,
        live: true,
        hashtags: true,
        timestamp: true,
        avatars: true,
        toptweets: true,
        behavior: 'default'
      }
    }).render().start();
    &lt;/script&gt; ');  
</code></pre>

<p>or what I have to write each script as a seperate line like this?</p>

<pre><code>document.write('&lt;script src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt; ');
&lt;script&gt;
document.write('new TWTR.Widget({
  version: 2,
  type: 'search',
  search: '@BigNotch',
  interval: 6000,
  title: 'Follow Me On Twitter',
  subject: 'BigNotch',
  width: 180,
  height: 300,
  theme: {
    shell: {
      background: '#ebebeb',
      color: '#969396'
    },
    tweets: {
      background: '#ffffff',
      color: '#000000',
      links: '#bbbcbd'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
&lt;/script&gt; ');   
 }
</code></pre>

<p>I tried THIS, but DW gave me a syntax error. Here is the ENTIRE script i'm writing.</p>

<pre><code>  &lt;script type="text/JavaScript"&gt;
&lt;!--
function changTwitter() {
var currentTime = new Date().getHours();    

 if (7 &lt;= currentTime&amp;&amp;currentTime &lt; 17) {

       document.write('&lt;' + 'script&gt;
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: '@BigNotch',
  interval: 6000,
  title: 'Follow Me On Twitter',
  subject: 'BigNotch',
  width: 180,
  height: 300,
  theme: {
    shell: {
      background: '#242124',
      color: '#f0af4d'
    },
    tweets: {
      background: '#333333',
      color: '#c2c2c2',
      links: '#f7bc63'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
&lt;/' + 'script&gt; ');   
 }

 else {
      document.write('&lt;' + 'script&gt;
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: '@BigNotch',
  interval: 6000,
  title: 'Follow Me On Twitter',
  subject: 'BigNotch',
  width: 180,
  height: 300,
  theme: {
    shell: {
      background: '#17d1ff',
      color: '#ff8fda'
    },
    tweets: {
      background: '#ededed',
      color: '#383838',
      links: '#ff8aed'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
&lt;/' + 'script&gt; ');

  }

      }
</code></pre>
