javascript onerror attribute


  Translation results:

on

英[ɒn]   美[ɑ:n]  

prep. (indicating direction) to; (indicating object) to; (indicating position) on...; (indicating time) at the time of...

adv. (put, wear, connect) on; forward, (continue) go on

adj. active situation, state ;Used;Occurring;Planned

error

UK[ˈerə(r)] US[ˈɛrɚ]

n. Error, negligence; [Law] mistrial, violation of law; [Number] Error

Plural: errors

javascript onerror attributesyntax

Function: Triggered when an error occurs during document or image loading. This event handler is called if an error occurs while loading the document or image.

Syntax: onerror="SomeJavaScriptCode"

Parameters: SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.​

javascript onerror attributeexample

<html>
<body>

<img src="image.gif"
onerror="alert('图片不存在')">

<p>在本例中,我们引用的图片不存在,所以弹出一个提示框。</p>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A