Javascript examples for DOM HTML Element:Image
change the src of an image to a variable in Javascript
<!doctype html> <html> <head> <script> function setImage(){/*from w w w.jav a2s . co m*/ var thumbPrefix = "http://your server.com/"; var thumbSuffix = "/default.jpg"; var vidCode = ['f1','a6','P4']; var thumb1Url = thumbPrefix + vidCode[0] + thumbSuffix; document.getElementById('pie').src=thumb1Url; } </script> </head> <body onload="setImage"> <img src="" id="pie"> </body> </html>