为什么不“加载”?绑定到
我想要一个在
// Create element
var $applet = $("<applet></applet>");
// Attach handler
$applet.load(function() {
alert('applet loaded');
});
// Set attributes
$applet.attr({
style: 'position:absolute;left:-1px',
name: 'TiddlySaver',
code: 'TiddlySaver.class',
archive: 'TiddlySaver.jar',
width:'1',
height:'1',
});
为什么不为
I want a callback that is executed after an <applet> element is loaded:
// Create element
var $applet = $("<applet></applet>");
// Attach handler
$applet.load(function() {
alert('applet loaded');
});
// Set attributes
$applet.attr({
style: 'position:absolute;left:-1px',
name: 'TiddlySaver',
code: 'TiddlySaver.class',
archive: 'TiddlySaver.jar',
width:'1',
height:'1',
});
Why is the 'load' event handler not executed for an <applet> element? If I change the <applet> to an <img> element (with valid src attribute) the handler is executed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据HTML 4.01(网页的基本标准),只有两个元素具有onload属性:body和frameset。一些其他元素也支持它作为专有扩展(图像相当常见),但您不应该期望任何其他元素这样做。
HTML5 要求所有 HTML 元素(除了特殊的 body 之外)都支持加载事件,但您不能依赖它被广泛或完全实现(如果有的话)。
According to the HTML 4.01 (which is the fundamental standard for web pages), only two elements have an onload attribute: body and frameset. Some other elements also support it as a proprietary extension (image is fairly common), but you should not expect any other element to do so.
HTML5 requires all HTML elements (except body, which is peculiar) to support a load event, but you can't depend on it being widely or fully implemented yet (if ever).
来自 jQuery 文档:
这可能就是原因。
From the jQuery documentation:
That might be the reason why.