问题描述
Mozilla的MDN 通知加载具有此存根的事件:
并链接到
标准1 ,它通知
因此,相关的 onload
处理程序和 load
事件似乎设计为可与Element一起使用.看来这样的元素是< img>
,指示该元素的加载.
It seems that the related onload
handler, and the load
event is hence designed to work with Element. It seems such an element is <img>
to indicate the loading of this.
请注意,现在我在窗口/文档上的 load
事件还指示其所包含的元素的加载状态,但有些元素可以
Please note that I now that the load
event on the window/document indicates also the load state of its contained Elements but some Element can
a)更改其 src
/ href
属性(< img>
,< script>
,< link>
,....)b)或其内联内容(< style>
,< script>
)
a) change their src
/href
property (<img>
, <script>
, <link>
,....)b) or their inline content (<style>
, <script>
)
.
有了这个问题,我想知道哪些元素支持 load
事件 onload
.Handler".
With this question I seek help knowing "which Elements support the load
Event, onload
.Handler.
我在Chromium和Firefox中对此进行了测试,并且似乎支持< style>
,< script>
I tested this in Chromium and Firefox and it seems it is supported in<style>
, <script>
var styleElement = document.createElement("style");
styleElement.onload = function() {
console.log("styleElement onload called");
};
document.head.appendChild(styleElement);
// output: "styleElement onload called";
但是我不确定所发现的行为是否确实在标准中指定的任何地方?
but I am unsure if the discovered behavior is actually anywhere specified in the stanards?
推荐答案
支持的HTML标记如下:< body>,< frame>,< iframe>,< img>,< input type ="image"> ;,< link>,< script>,< style>
Supported HTML tags are as follows : <body>, <frame>, <iframe>, <img>, <input type="image">,<link>, <script>, <style>
我在< h1>上进行了测试标签,但没有成功
I tested it on <h1> tag but it didn't work out
<h1 onload="myFunction()">Hello World!</h1>;
有关更多详细信息,请访问 W3学校
For more details, visit W3 schools
这篇关于哪些HTML5元素具有onload/“加载事件"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!