From f212890e3d437c2ca12e63efc5b598e3008b2fe3 Mon Sep 17 00:00:00 2001 From: cooperok Date: Sat, 18 Aug 2012 15:33:42 +0300 Subject: [PATCH] Added listener on javascript error to show all images --- Source/onerror.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Source/onerror.js diff --git a/Source/onerror.js b/Source/onerror.js new file mode 100644 index 0000000..5ca8b77 --- /dev/null +++ b/Source/onerror.js @@ -0,0 +1,34 @@ +/*Adding onerror listener to show all images, if an error will occur*/ +window.onerror = function() { + + window.onload = function() { + + /*Getting all images*/ + var images = document.getElementsByTagName('img'); + + if(images.length > 0) { + + var src = null; + + for( var i = 0; i <= images.length; i++ ) { + + if( typeof images[i] != 'undefined' ) { + + src = images[i].getAttribute('data_src'); + + /*If specified real src in image, change it*/ + if( src ) { + + images[i].src = src; + + } + + } + + } + + } + + } + +} \ No newline at end of file