Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a src attribute be added to a script tag after onload? 1

Status
Not open for further replies.

simon373

Programmer
Oct 25, 2006
25
0
0
Hi,

I am trying to retrieve a variable from an xml document and pass it to a script tag src attribute using DOM setAttribute. The variable is not retrieved until the onload event, so the script will already have run once with no src attribute.

var photourl = response.getElementsByTagName("photourl")[id].firstChild.data;
var photourlelement = document.getElementById("photourlholder");
photourlelement.setAttribute("src",photourl);

<script id="photourlholder" language="JavaScript" type="text/JavaScript"></script>

When I do this I don't get any error message, but the script does not appear to run. Any suggestions please?

Many thanks

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top