NameSilo

Hide Dead Images with Javascript

Spacemail by SpaceshipSpacemail by Spaceship
Watch

onewordonly

Established Member
Impact
108
Hello,
I have a page the gets images from a 3rd party and I want to use a script that will hide images that are not working. This site is not using php so I thought Javascript would be good.

I can't seem to find anything?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Hmm.. I'm not entirely sure if this is possible with Javascript, becuase it is a client side language. You could do with something server side like a cron job that say every hour would check the links and then if they do not exist or something.. delete them from the database, assuming you are using one..
 
0
•••
ok I see, well it is on a database with ASP this site, just a very small site using an access database which is updated once a week.... But I do have this problem with other sites that use PHP & MySql when I use merchant datafeeds and there is often broken images in the datafeed. Yes I think I know what your getting at, I might have to come up with something that looks up the images in the database.
 
0
•••
I think onerror should work for that, did it a quick run in FF2 and IE6/7 and seems to work there at least:
Code:
<img src="imglink.jpg" onerror="this.style.display='none'">
Checking them serverside is probably a better idea though.
 
1
•••
cerebus said:
I think onerror should work for that, did it a quick run in FF2 and IE6/7 and seems to work there at least:
Code:
<img src="imglink.jpg" onerror="this.style.display='none'">
Checking them serverside is probably a better idea though.

hey that is perfect & exactly what I'm looking for, thanks a lot & I have given you rep points. It also works with this in FF 1.07 & IE 6.1
 
0
•••
Simple and effective. Nice code cerebus
 
0
•••
onerror! thats one you dont see every day.
 
0
•••
Is there some reason alt tags wont work here??
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back