Jump to content

Year

Day

24 ways to impress your friends

Vote down?

  • Four Feathers

    Could this be handy to use too?

    and what about removing the inline onload handler of the image since that code wont validate when using a strict doctype?

    Since we use DOM why not do this:

    Create an object:

    document.getElementById(‘LoadedImg’)

    loadImg = function(){

    // check if has loaded allready, and if so, abandon it.

    if( this.hasloaded ) { return; }

    // if not, mark it as having already run

    this.hasloaded = true;

    alert(‘Now that I have your attention…’);

    this.parentNode.removeChild(this);

    }

    document.getElementById(‘LoadedImg’).hasloaded = false;

    document.getElementById(‘LoadedImg’).onload = loadImg;

    if(document.getElementById(‘LoadedImg’).complete) {

    document.getElementById(‘LoadedImg’).onload();

    }