Music. Coding. Gaming. Life.

JavaScript Red X remover

Posted Tuesday, June 6th, 2006 11:57:00 pm
After a bit of frustration at the front page of OSMusic.Net having red X images, I decided to write something that will check for bad and broken images and remove them altogether from the display. It's a drity hack, but it works rather well.

function checkImages() {
 var all = document.all ? document.all : document.getElementsByTagName('*');
 for (var i = 0; i < all.length; i++)
 {
  if (all[i].tagName == "IMG")
  {
   if (all[i].complete == false)
   {
    all[i].style.visibility = "hidden";
    all[i].style.display = "none";
   }
  }
 }
}

<body onload="checkImages();">

Comments

Loading...
roncli.com Media Player