|
Hi chaps,
I have this social networking script at the foot of my page:
<script language="JavaScript" type="text/javascript">
var addtoLayout=0;
var addtoMethod=1;
var AddURL = encodeURIComponent("url goes here");
var AddTitle = escape("title goes here");
</script>
<div id ="bobbus">
<script language="JavaScript" src="scripts/addto/addto.js" type="text/javascript"></script>
</div>
However, I don't want it to load immediately but only after a 5 second timer expires. Using a javascript timer and a .innerhtml command I can do all sorts of things except make this work.
Here's the code snippet:
varHTML0 = "Hello World";
varHTML1 = "<script language='JavaScript' src='scripts/addto/addto.js' type='text/javascript'></script>";
document.getElementById('bobbus').innerHTML = varHTML1;
The problem is that I have absolutely no idea why this won't work....
Substituting varHTML1 for varHTML0 results in hello world as expected.
Clearly, when using the timer the div with ID bobbus doesn't contain anything at all.
I've tried escaping the characters in every way I can think of but to no avail. Is it because you just can't do this with bits of script and expect the browser to process the newly inserted text (script) as normal?
|