WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum

Go Back   WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum > Free Section > Shooting The Shit

Shooting The Shit This is where the action is for all webmasters alike. Anything goes, seriously. Come meet and network with your peers, it's a fun way to take a break out of your busy day of posting at other boring forums.


Welcome to the WickedFire - Affiliate Marketing Forum - Internet Marketing Webmaster SEO Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 04-18-2007, 05:20 PM   #1 (permalink)
Pwner.
 
DaveEMG's Avatar
 
Join Date: Jan 2007
Location: Silicon Valley, CA
Posts: 911
iTrader: 0 / 0%
DaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond repute
Help Detecting broken images with javascript?

Alright party people. Here's the pop quiz for today (because I need help).

Is there a way, in Javascript, cross-browser compatible, to detect a broken image on a page, and replace it with a "image not found" placeholder?
__________________
"If you ain't first you're last..." ... "Oh hell, Son, I was high that day. That doesn't make any sense at all, you can be second, third, fourth... hell you can even be fifth."

DaveEMG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2007, 05:27 PM   #2 (permalink)
 
Stanley's Avatar
 
Join Date: Jun 2006
Location: Coast to Coast
Posts: 3,334
iTrader: 2 / 100%
Stanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond repute
okay strictly speaking, you would need to read the return headers to see if it's a 404 -- but I have no idea if Javascript allows you to read headers
there is a workaround however - you can create an xmlHTTPrequest object and use it to request a PHP code to run the file_exists function -- but this isn't very fast or efficient

you're better off checking for the problem using PHP while the page is still loading, as opposed to using Javscript

PS: I'm not a JS guru so wait for more replies before you decide
__________________
@soluh
Stanley is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2007, 05:39 PM   #3 (permalink)
Pwner.
 
DaveEMG's Avatar
 
Join Date: Jan 2007
Location: Silicon Valley, CA
Posts: 911
iTrader: 0 / 0%
DaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond reputeDaveEMG has a reputation beyond repute
It's ASP... Hmmm... I guess I can do a server-side file request, but that might require a lot of processing on the server side. I'd prefer to do it client side if I could. I was hoping there was some quick jscript shortcut to make this happen.
__________________
"If you ain't first you're last..." ... "Oh hell, Son, I was high that day. That doesn't make any sense at all, you can be second, third, fourth... hell you can even be fifth."

DaveEMG is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2007, 06:22 PM   #4 (permalink)
Senior Member
 
Join Date: Jun 2006
Posts: 168
iTrader: 1 / 100%
wdmny has a spectacular aura about
Set the image object .onLoad to fire some code. If the code never fires, the image hasn't loaded. Set a timer to give the image a certain amount of time to load, then set it as broken if the code doesn't fire by then.
wdmny is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2007, 07:33 PM   #5 (permalink)
 
Stanley's Avatar
 
Join Date: Jun 2006
Location: Coast to Coast
Posts: 3,334
iTrader: 2 / 100%
Stanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond reputeStanley has a reputation beyond repute
Quote:
Originally Posted by wdmny View Post
Set the image object .onLoad to fire some code. If the code never fires, the image hasn't loaded. Set a timer to give the image a certain amount of time to load, then set it as broken if the code doesn't fire by then.
yeah that's a good idea. I'm not sure on the best way to trigger this, because different connection speeds = different load times
maybe you can setup a cron job to periodically check which images exist on the server

I'm not sure whether or not you're the same guy but does this have something to do with website screenshots?
__________________
@soluh
Stanley is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-19-2007, 12:16 AM   #6 (permalink)
Domainers...
 
bubbles's Avatar
 
Join Date: Apr 2007
Location: Colorado
Posts: 849
iTrader: 3 / 100%
bubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond reputebubbles has a reputation beyond repute
I would time it. I know when RSnake or someone came up with a portscanner with/without javascript, they timed how long it took for a request to complete, to see if a server existed on that IP/port. I'm sure you could do the same for an image. Just setTimeout();
__________________
Best Regarded
Google Webmaster Mr Khanceff John
http://twitter.com/johnwineman

bubbles is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-19-2007, 04:59 PM   #7 (permalink)
I'm a Coder
 
Join Date: Mar 2007
Posts: 626
iTrader: 1 / 100%
DomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond reputeDomainRealty has a reputation beyond repute
Personally, I would preload the images with a if/else statement like this:

if(!image.load(args)) { error(); }

Not quite sure about the syntax, but that should do it.

Jason
__________________
COPEAC + NEVERBLUE ADS = MONEY!
DomainRealty is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:53 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
WickedFire.com Copyright © 2009 - WickedFire is an international registered Trademark of WickedFire LLC. You may not use any of our trademarks, copyrights, content, or images without a written approval by members of WickedFire LLC.