在每一个匹配元素的error事件中绑定一个处理函数。
对于error事件,没有一个公众的标准。在大多数浏览器中,当页面的JavaScript发生错误时,window对象会触发error事件;当图像的src属性无效时,比如文件不存在或者图像数据错误时,也会触发图像对象的error事件。
如果异常是由window对象抛出,事件处理函数将会被传入三个参数:
1. 描述事件的信息 ("varName is not defined", "missing operator in expression", 等等.),
2. 包含错误的文档的完整URL
3. 异常发生的行数
如果事件处理函数返回true,则表示事件已经被处理,浏览器将认为没有异常。
返回值:jQuery
参数:
fn(Function) : 在每一个匹配元素的error事件中绑定的处理函数。
示例:
在服务器端记录JavaScript错误日志:
$(window).error(function(msg, url, line){
jQuery.post("js_error_log.php", { msg: msg, url: url, line: line });
});
隐藏JavaScript错误:
jQuery 代码:
程序代码
$(window).error(function(){
return true;
});
给你IE的用户隐藏无效的图像:
jQuery 代码:
程序代码
$("img").error(function(){
$(this).hide();
});
分享到:
相关推荐
$.ajaxError( fn( event, XHR, options, thrownError ) ) $.ajaxSend( fn( event, XHR, options ) ) $.ajaxStart( fn( ) ) $.ajaxStop( fn( ) ) $.ajaxSuccess( fn(event, XHR, options) ) Miscellaneous str....
$.print = $.fn.print = function () { // Print a given set of elements var options, $this, self = this; // console.log("Printing", this, arguments); if (self instanceof $) { // Get the node if it...
jQuery.fn.extend(object) jQuery.extend(object) 多库共存 jQuery.noConflict([ex]) 属性 属性 attr(name|pro|key,val|fn) removeAttr(name) prop(n|p|k,v|f) removeProp(name) CSS 类 addClass(class...
fn.apply(this, arguments); } this.on(event, on); return this; }; // Unbinds an entire group WildEmitter.prototype.releaseGroup = function (groupName) { var item, i, len, handlers; for (item in...
#9794:jQuery.fn.data() correctly handle access to arbitrary data property values #10016:Cannot retrieve “false-y” values under key names with dashes using jQuery.data method #10080:unload from ...
To copy text or to enlarge the log window double click on it. Supported Obfuscators: 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.14 [June 16, 2007]' , 'Jos van der Zande AutoIt3 Source ...
throw new Error("this method can only execute in IE"); } } function $addEL(n,e,l,b){ if ($IE){ if (n["$__listener_"+e]==null){ var lst=function (e){ ...
# Sortable Sortable is a <s>minimalist</s> JavaScript library for reorderable drag-and-drop lists. ... ## Features ... * Can drag from one list to another or within the same list * CSS animation when ...
$.fn.jqzoom = function(options) { var settings = { zoomType: 'standard', //standard/reverse/innerzoom zoomWidth: 400, //zoomed width default width zoomHeight: 400, //zoomed div default width ...
+ ajax的error回调的第二个参数可能值"timeout", "error", "notmodified" 和 "parsererror" + ajax参数xhr * animate 的duration为0的问题 * show, hide, toggle, slideDown, slideUp, slideToggle 在jQuery 1.3中,...
+ ajax的error回调的第二个参数可能值"timeout", "error", "notmodified" 和 "parsererror" + ajax参数xhr * animate 的duration为0的问题 * show, hide, toggle, slideDown, slideUp, slideToggle 在jQuery 1.3中,...
jQuery的获取 围绕jQuery的基于约定的包装器,可在get... fetch = { fn_text : "There has been an error:" , do_globals : true } ; </ script > 如果do_globals为true,则它将实用程序功能也导出到window中:
Some Final Comments on the MOV Instructions <br>4.9 Laboratory ...Window 4.9.5.3 The Memory Window 4.9.5.4 The Register Window 4.9.5.5 The Command Window 4.9.5.6 The Output Menu Item ...
[3108422] Timing window in NE2K emulation [3084390] Bochs won't load floppy plugin right on startup [3043174] Docbook use of '_' build failure [3085140] Ia_arpl_Ew_Rw definition of error [3078995...
<html><title>ERROR代码测试</title><body> //ServerName NetShowServer = "" ; //Path //var mPath = NetShowServer + "/entercp/mnet/"; var mPath = NetShowServer + ""; var bgImage = "bg.gif"; var ...
特征同时使用Fn() -> Result和Future (通过默认的futures-support功能可选)。 退避策略: constant 、 exponential 、 equal_jittered 、 full_jittered 故障检测策略: consecutive_failures , success_rate_...
乌鸦 此板条箱仍处于开发初期,高度不稳定且功能尚未完善 一个简单且相当有效的基于像素的2D图形库... window :: WindowBuilder, }, Context, DrawConfig, Texture, }; fn main () -> Result <(), crow::Error> {
22. Five generic tasks are error control, flow control, segmentation and reassembly, multiplexing, and connection setup. Yes, these tasks can be duplicated at different layers. For example, error ...