...

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



SickMothaF
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"
onclick="javascript:loadXML();"/>

And this is the empty div I use :


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



Please HELP! Any suggestions?

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



<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum