jQuery.error()不适用于iframe。 [英] jQuery.error() is not working for iframe.
本文介绍了jQuery.error()不适用于iframe。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jquery来检测 iframe
是否无法加载或页面不存在,但下面的代码无效:
I'm trying to use jquery to detect whether an iframe
fails to load or the page doesn't exist, but the code below isn't working:
$('#frame').error(function(){
//code here
});
推荐答案
对文档说:
使用iframe上的.error()似乎永远不会触发(即使
.load()会在成功加载iframe时触发)。
Using .error() on an iframe never seems to trigger (even though .load() will trigger on a successful iframe load).
此事件似乎不适用于此用例。
This event does not appear to be designed to work in this use case.
这个问题解释了如何做到这一点。
The answers to this question explain how to do it.
这篇关于jQuery.error()不适用于iframe。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文