Question re Javascript-html coding This is for a Javascript application that is only intended to run on a local machine, accessing many large image files from local disk. Original code like this: ---------------------------- <-- Then html stuff including some control buttons, each one like this --> <--then a chunk of javascript related to the buttons --> ---------------------------- The thing works OK, see http://everist.org/NobLog/20150424_js_animated_gallery.htm Now I want to extend it, so all image pathnames are defined as js constants and vars. Some will remain fixed during lifetime of the browser page, others will change by user actions. I'm stuck with one part of this. How to get the html parser to pay attention to script blocks WITHIN statements? Specifically, I want to do a document.write() within the image src string. Like: But the html parser doesn't seem to notice scripts inside html elements. I'm a javascript nubie, so I may have some stupid misconception of how it all works. Am I just doing it wrong, or is this fundamentally impossible due to reasons? If impossible, well shit. Effectively a bug from poor integration between html and Javascript. Here's an example: ----------------------------- <-- some html stuff --> <-- including some control buttons, each one like this --> <--then a chunk of javascript related to the buttons --> ------------------------------ In debugger, the img element appears as: The intent was to get this: