Results 1 to 3 of 3

Thread: I can't figure out whats wrong...

  1. #1
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default I can't figure out whats wrong...

    These 2 lines are getting me:
    Code:
    frame.contentDocument.getElementsByTagName ("html") [0].innerHTML = theXML;
    alert (frame.contentDocument.getElementsByTagName ("html") [0].innerHTML);
    It doesn't appear on screen, but then the alert says what I want it to say.
    The entire code is:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    window.onload = function () {
    for (var i = 0; i < document.getElementsByTagName ("xml").length; i = i + 1) {
    var tag = document.getElementsByTagName ("xml") [i];
    var theXML = "<?" + tag.getAttribute ("doctype") + "?>" + tag.innerHTML;
    tag.innerHTML = "";
    var frame = document.createElement ("iframe");
    frame.setAttribute ("src","about:blank");
    tag.appendChild (frame);
    frame.contentDocument.getElementsByTagName ("html") [0].innerHTML = theXML;
    alert (frame.contentDocument.getElementsByTagName ("html") [0].innerHTML);
    }
    }
    </script>
    </head>
    <body>
    <xml doctype='version="1.0" encoding="ISO-8859-1"'>
    <root>
    hahaha
    </root>
    </xml>
    </body>
    </html>
    I did it before with it writing about:blank, but right now I can't figure out whats wrong.

  2. #2
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    Now I'm more puzzled. It works when I click if I put it in an onclick event, it just doesn't seem to want to work immediately, I even tried putting it in a different function. Might this be a bug?

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    frame.setAttribute ("src","about:blank");
    -- perhaps it hasn't finished loading about:blank? This doesn't block, you know. Make use of onload.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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