【发布时间】:2014-07-01 14:11:47
【问题描述】:
在下面的代码中,所有的 onerror 事件都可以正常工作,除了“Object”标签中提到的那个。没有名为“helloworld.swf”的文件,但未触发 onerror 事件。谁能解释一下。
<html>
<head>
<script type="text/javascript">
<!--
window.onerror = function (msg, url, line) {
alert("Message : " + msg );
alert("url : " + url );
alert("Line number : " + line );
}
//-->
</script>
</head>
<body>
<p>Click the following to see the result:</p>
<form>
<input type="button" value="Click Me" onclick="myFunc1();" /><br/>
<input type="text" dir="rtl">
</form>
<object width="400" height="400" data="helloworld.swf" onerror="alert('helloworld.swf not found')"><br/>
</object>
<img src="myimage.gif" onerror="alert('image not found')"/><br/>
</body>
</html>
P.S : 请参阅链接“http://www.w3schools.com/jsref/event_onerror.asp”,其中明确表示“object” HTML 标记支持 onerror 事件。
【问题讨论】:
-
w3c 和 mdn 没有对象标签的 onerror 属性。参考:w3.org/wiki/HTML/Elements/object 和 developer.mozilla.org/en-US/docs/Web/HTML/Element/object。请参考 MDN 或其他标准化网站。他们有良好和标准的文档。
-
w3fools.com 请使用其他文档
标签: javascript html onerror