views:

52

answers:

2

Hi,

Is there a way to prevent the error "This webpage is not available." from displaying within an iframe that displayed on another site?

For example, if I have a website and I want to display my Facebook fans in a box, one way to display it is with an iframe (typically Facebook supplied code). However, if for some reason Facebook is down or slow to respond (like it is right now), I get the following displayed on my website where the iframe should be displayed:

This webpage is not available.

The webpage athttp://www.facebook.com/plugins/likebox.php?id=xxxxxxxxxx&width=182&connections=6&stream=false&header=true&height=287might be temporarily down or it may have moved permanently to a new web address.

• More information on this error Below is the original error message Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.

If Facebook (or the other website) is not available, I'd be happy not displaying anything, or displaying a graphic of the same size (height/width), or a host of other alternatives EXCEPT displaying an error on my homepage! It makes my site look broken to users.

Any and all ideas are welcome! Thanks in advance

+2  A: 

You can use the iframe's onerror="" property to do something creative. Consider this:

<iframe src="foo.bar" onerror="this.location.reload();" />

Hope this helps

mattbasta
*onerror* for iframe elements is part of the HTML5 specification and, as far as I can tell, is only supported in the latest versions of Chrome and Safari. Firefox, IE and Opera don't support it, although it can't hurt to add this so that it will work when those browsers implement it.
Andy E
+1  A: 

If you are doing anything on the server-side you can test that URL and see if it returns a 404 error

JiminyCricket
That won't work because you need the clients credentials from their browser to display facebook content .
Byron Whitlock
yes, but not if its public content
JiminyCricket