simon373
Programmer
- Oct 25, 2006
- 25
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
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