Page is a not externally linkable
- WebmasterWorld
-- Webmaster General
---- how to track broken image links?


Achernar - 5:22 pm on Apr 15, 2008 (gmt 0)


On one of my sites I've set up a javascript system that notifies the site when images have failed to load.

Basically, you end each page with:
<script type="text/javascript">chkI()</script>

and define chkI()
function chkI(){
function imgE(e){
e=e¦¦event;
e=e.target¦¦e.srcElement;
if(e.Cap)return;
e.OK=0;e.Cap=1
}

function imgOK(e){
e=e¦¦event;
e=e.target¦¦e.srcElement;
e.OK=1;e.Cap=1
}

for (var i=0,e;e=document.images[ i ];i++) {addEvent(e,'error',imgE);addEvent(e,'load',imgOK)}
}

addEvent() is a standardized method for addEventListener() (Mozilla) and attachEvent() (IE)

You add a body.onload event that loops through the images and detects which have failed. Once done, you can report failed urls to your server by requesting a dummy image with urls as parameters (after '?').

When you parse you server logs you'll notice all image errors (temporary and permanent).

[edited by: Achernar at 5:23 pm (utc) on April 15, 2008]


Thread source:: http://www.webmasterworld.com/webmaster/3627438.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com