admin管理员组

文章数量:1414620

I have a function called loadXMLDoc which takes text from the url parameter and sets it inside the parameter name of another page that has the same span name. im trying to use onload to make it into one line by using onload instead of having it in 2 lines.

<span id="span number1" onload="loadXMLDoc('www.url','span number1')"></span>

I have a function called loadXMLDoc which takes text from the url parameter and sets it inside the parameter name of another page that has the same span name. im trying to use onload to make it into one line by using onload instead of having it in 2 lines.

<span id="span number1" onload="loadXMLDoc('www.url.','span number1')"></span>

<span id="span number1"></span>
<script> loadXMLDoc("www.url.","span number1");</script>
Share Improve this question asked Feb 12, 2015 at 15:01 Safi NaseenSafi Naseen 1231 gold badge2 silver badges4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

That's not possible. onload works only on external resources (images, frames, ...) and the body itself.

Depending on your page structure you could add onload="loadXMLDoc('www.url.','span number1')" to the <body> tag. Otherwise your second example looks correct and should also work.

本文标签: javascripthow to add onload to spanStack Overflow