roncli.com blog
The blog of roncli
roncli.com blog
roncli.com
blog
Profile
roncli
Houston, Texas, United States
Labels
Coding
CTG Music
Editorials
Games
Miscellaneous
Music
Servers
Silliness
Software
Sports
Trax in Space Beta
Weather
Recent Posts
Port Forwarding: Finally
Another PDF Viewer
Overcomplication
Yet Another Long Night
The Long Weekend
BOINCing around
So Much To Do
A Day Off... Kind of
Still Catching Up
Catching Up
Tuesday, June 06, 2006
JavaScript Red X remover
Posted: 6:57:00 PM 0 comments
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();">

Labels: , ,




0 Comments

Post a Comment