Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem using document.write() with XSL under Gecko

    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?

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    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).
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #5
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    <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 = '';
                            }
    
    </script>
    
    <!-- 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>
    
    </div>
    Last edited by Leksiq; 09-09-2010 at 02:24 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •