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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Javascript function can't load on onLoad, works only fired with button?!

    Hi, I have the folowing problem. I have a function to parse xml in Firefox. The data is filled in an empty div. I have a buton that trigers the parse function. The function works,fills the div with the data, but when I try to auto parse it, onload, it's not working.

    I've tryed all the diferent ways of onLoad combinations and scripts. I don't think the problem is with the auto load because the function works. I think it is something to deal with the fact that I am filling a div. I also tryed with creating a div node. Also no change.

    here is some code :

    Code:
    function loadXML()
    {
    ...
    document.getElementById("result").innerHTML = (html != null) ? html : "XSLT Failed!"
     }
    ...


    The button code, which works, is :

    Code:
    <input type="button" value="Load XML"
    onclick="javascript:loadXML();"/>
    And this is the empty div I use :

    Code:
    <div style="padding:2px;" id="result">sdsdgsd</div>

    Please HELP! Any suggestions?
    ..::ignorance is bliss::..

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    It works for me.

    Code:
    <html>
    <head>
    <script language="javascript">
    
    function loadXML(){
    
      html='test';
      document.getElementById("result").innerHTML = (html != '') ? html : "XSLT Failed!"
    
    }
    </script>
    
    </head>
    
    <body onload="loadXML();">
    
    <div style="padding:2px;" id="result">sdsdgsd</div>
    <input type="button" value="Load XML" onclick="javascript:loadXML();"/>
    
    </body>
    
    </html>


  •  

    Posting Permissions

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