[Greasemonkey] DOM vs document.write

Chris Roos chris at seagul.co.uk
Fri Mar 10 10:33:10 EST 2006


Hi,

This is probably not the most relevant place for this question, as it 
doesn't need greasemonkey to be explained.  However, I did come across 
when trying something with gm and didn't really know where else to ask.

I have a remote javascript that uses document.write to insert an image 
into a page.

If I place normal <script src='remote.js'.. (client js) in my page then 
all works fine and the image is rendered.

The problems appear when I try to write client js into the page dynamically.

If I use document.write to create the client js then it works as 
expected.  If I use the dom to create the client js then although the 
image is rendered, it appears that the browser (ff 1.5) is still trying 
to 'do' something - page load progress doesn't finish.

Using the DOM for the client js works fine providing I change the remote 
to use the DOM too.

My question is why does using the DOM for the client js with 
document.write for the remote js cause problems.  I'm guessing it's to 
do with the different points that the code gets executed during page 
render but was interested to know for sure.

Thanks for your help in advance,

Chris


More information about the Greasemonkey mailing list