View Full Version : Javascript function can't load on onLoad, works only fired with button?!

08-09-2006, 03:46 PM
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 :

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

The button code, which works, is :

<input type="button" value="Load XML"

And this is the empty div I use :

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

Please HELP! Any suggestions?

08-09-2006, 05:29 PM
It works for me.

<script language="javascript">

function loadXML(){

document.getElementById("result").innerHTML = (html != '') ? html : "XSLT Failed!"



<body onload="loadXML();">

<div style="padding:2px;" id="result">sdsdgsd</div>
<input type="button" value="Load XML" onclick="javascript:loadXML();"/>