i have the folowing code:
window.document.getElementById("bufferTopic").innerHTML = "<img src='einstein/einstein.png' width='800' height='600'><script type='text/javascript' language='javascript'>alert('test');</script>"
i have it within a script file. the idea is to cache some images inside a div and when it completes run a script.
but it is not working.
any comments on why it is not working?
thanks.
EDIT: the script loads the image alright though.
You are injecting javascript into the page, after it has loaded.
It will not execute just because it is now on the page.
You can read about the javascript execution model here.
Not sure why you can’t simply write out your javascript after inserting the image: