Gollum
08-11-2003, 05:58 AM
Can anyone confirm whether or not this is a good idea...
I want to create HTML in the page using document.write and then immediately afterwards use document.getElementById to access one of the objects defined in it. e.g.
[code]
<html>
...
<script>
document.write('<span id="mySpan"></span>');
var oSpan = document.getElementById('mySpan');
// then use DOM to fill the span
</script>
...
</html>
I've seen a few javascripts doing this, however I've read that document.write may buffer the text and the only way to guarantee it's processed is to call document.close - which can't be done here
I want to create HTML in the page using document.write and then immediately afterwards use document.getElementById to access one of the objects defined in it. e.g.
[code]
<html>
...
<script>
document.write('<span id="mySpan"></span>');
var oSpan = document.getElementById('mySpan');
// then use DOM to fill the span
</script>
...
</html>
I've seen a few javascripts doing this, however I've read that document.write may buffer the text and the only way to guarantee it's processed is to call document.close - which can't be done here