You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entries/error.xml
+6-5
Original file line number
Diff line number
Diff line change
@@ -34,22 +34,23 @@ $( "#book" )
34
34
})
35
35
.attr( "src", "missing.png" );
36
36
</code></pre>
37
-
<p>If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed:</p>
37
+
<p>If the image cannot be loaded (for example, because it is not present at the supplied URL), the alert is displayed:</p>
38
38
<p>
39
39
<samp>Handler for .error() called.</samp>
40
40
</p>
41
41
<divclass="warning">
42
-
<p>The event handler <em>must</em> be attached before the browser fires the error event, which is why the example sets the src attribute after attaching the handler. Also, the error event may not be correctly fired when the page is served locally; <code>error</code> relies on HTTP status codes and will generally not be triggered if the URL uses the <code>file:</code> protocol.</p>
42
+
<p>The event handler <em>must</em> be attached before the browser fires the <code>error</code> event, which is why the example sets the <code>src</code> attribute after attaching the handler. Also, the <code>error</code> event may not be correctly fired when the page is served locally; <code>error</code> relies on HTTP status codes and will generally not be triggered if the URL uses the <code>file:</code> protocol.</p>
43
43
</div>
44
-
<p>Note: A jQuery error event handler should not be attached to the window object. The browser fires the window's error event when a script error occurs. However, the window error event receives different arguments and has different return value requirements than conventional event handlers. Use <code>window.onerror</code> instead.</p>
44
+
<p>Note: A jQuery <code>error</code> event handler should not be attached to the <code>window</code> object. The browser fires the <code>window</code>'s <code>error</code> event when a script error occurs. However, the window <code>error</code> event receives different arguments and has different return value requirements than conventional event handlers. Use <code>window.onerror</code> instead.</p>
<desc>To hide the "broken image" icons for IE users, you can try:</desc>
48
+
<desc>To replace all the missing images with another, you can update the <code>src</code> attribute inside the callback passed to <code>.error()</code>. Be sure that the replacement image exists; otherwise the <code>error</code> event will be triggered indefinitely.</desc>
49
49
<code><![CDATA[
50
+
// If missing.png is missing, it is replaced by replacement.png
0 commit comments