View Full Version : Problem using document.write() with XSL under Gecko

12-18-2002, 06:57 AM
Maybe it's just me, but has anyone else had a problem with using document.write() in a JavaScript that is inside an XSL file under Gecko?

It seems to work well for IE6, but Mozilla keeps crashing. Has anyone got any ideas? JKD, you seem to be the Gecko God... do you know?

12-18-2002, 12:51 PM
document.write() is an HTML-DOM method.

The result of an XSL transformation is XML, such as XHTML. Therefore, the document.write() method shouldn't be present.

Alex Vincent
12-18-2002, 11:31 PM
Crashing? You should probably file a bug for that at http://bugzilla.mozilla.org under XSLT, with keyword "crash", and also any Talkback ID you get from Mozilla Talkback (\bin\components\talkback.exe).

12-19-2002, 07:05 AM
I have sent it in to BugZilla. I was contacted and told that it would be fixed by the next release, which was supposed to be 1.2. I'm still having problems though.

JKD, thanks. I was unaware of that. The reason I ask is that I use QuickBooks at work. QuickBooks can export to Excel, which can save as XML. I've been using JavaScript to parse time and date data from the generated XML file, but I was hoping to use XSL instead, because CSS seems to work better on an XSLT page that with data imported into an HTML page for some reason.

Other JavaScript seems to work fine, including sending information to a SPAN tag using innerHTML... just no document.write();

Thanks anyways...

09-09-2010, 03:19 PM
If you should use inside an XSL file a script with document.write() and you cannot edit it(some counter for example), the next trick can help:

<script type="text/javascript">
// this is your script somewhere in HEAD
var document_write = '';
var obj = null;
document.write = function(str) {
document_write += str;
function begin(id) {
obj = document.getElementById(id);
function end() {
if(obj) {
obj.innerHTML = document_write;
document_write = '';


<!-- somewhere in BODY where you plan use another's script -->
<div id="some_id">
<script type="text/javascript">begin('some_id');</script>
<script type="text/javascript" src="http://www.other-domain.com/some_script_with_document_write.js"></script>
<script type="text/javascript">end();</script>