阻止 iframe“此网页不可用。”网站上显示错误

发布于 2024-09-15 08:05:22 字数 624 浏览 2 评论 0原文

有没有办法防止出现“此网页不可用”错误。从在另一个网站上显示的 iframe 中显示?

例如,如果我有一个网站,并且想在一个框中显示我的 Facebook 粉丝,显示它的一种方法是使用 iframe(通常是 Facebook 提供的代码)。但是,如果由于某种原因 Facebook 宕机或响应缓慢(就像现在一样),我的网站上应该显示 iframe 的位置会显示以下内容:

此网页不可用。

网页 在http://www.facebook.com/plugins/likebox.php?id=xxxxxxxxx&width=182&connections=6&stream=false&header=true&height=287可能 暂时关闭或者可能有 永久转移到新网站 地址。

• 有关此错误的更多信息 以下是原始错误消息 错误 324(net::ERR_EMPTY_RESPONSE): 未知错误。

如果 Facebook(或其他网站)不可用,我很乐意不显示任何内容,或显示相同尺寸(高度/宽度)的图形,或除了在我的主页上显示错误之外的许多其他替代方案!这让用户看起来我的网站已经损坏。

欢迎任何和所有的想法!提前致谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉栀 2024-09-22 08:05:22

您可以使用 iframe 的 onerror="" 属性来做一些有创意的事情。考虑一下:

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

希望这有帮助

编辑:这不再有效。

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

Edit: This no longer works.

别念他 2024-09-22 08:05:22

如果您在服务器端执行任何操作,则可以测试该 URL 并查看它是否返回 404 错误

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文