Javascript examples for DOM HTML Element:Image
Use function to return image src path
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> function getImagePath() {//from ww w.j av a 2 s . c o m return "http://www.java2s.com/style/download.png"; } </script> <!-- doesn't fire error event in FireFox --> <img src onerror="this.onerror=null; this.src=getImagePath();"> </body> </html>