You are adding the new script element in the head. Content in the head is not displayed, so even if the document.write call is succeeding, you won't see the text.
If you want content to be displayed, you have to add it to the body (as a child or other descendant) so move the script to the body:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>Document.write test</title>
<body>
<div>
<script type="text/javascript">
var script = document.createElement('script');
script.src = 'http://yoururl/test.js';
document.getElementsByTagName('div')[0].appendChild(script);
</script>
</div>
...
</body>
Note that you must still have a valid document after the document.write is finished.
The above does not work in Firefox 5, but does in IE 6. Note the warning about document.write in the HTML5 spec:
This method has very idiosyncratic behavior. In some cases, this method can affect the state of the the HTML parser while the parser is
running, resulting in a DOM that does
not correspond to the source of the
document. In other cases, the call can
clear the current page first, as if
document.open() had been called. In
yet more cases, the method is simply
ignored, or throws an exception. To
make matters worse, the exact behavior
of this method can in some cases be
dependent on network latency, which
can lead to failures that are very
hard to debug. For all these reasons,
use of this method is strongly
discouraged.**