Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
との間に違いはelement.addEventListener('load', func)ありelement.onload=funcますか?
element.addEventListener('load', func)
element.onload=func
DOMの「ロード」イベントはまだ非常に限られた方法でしか機能しません。つまり、たとえば、windowオブジェクト、画像、<script>要素に対してのみ起動します。直接onload割り当てについても同じことが言えます。これら2つの間に技術的な違いはありません。おそらく.onload =、クロスブラウザの可用性が高くなります。
window
<script>
onload
.onload =
ただし、<div>または<span>要素などにロードイベントを割り当てることはできません。
<div>
<span>