[javascript] How to add onload event to a div element

Try this.

_x000D_
_x000D_
document.getElementById("div").onload = alert("This is a div.");
_x000D_
<div id="div">Hello World</div>
_x000D_
_x000D_
_x000D_

Try this one too. You need to remove . from oQuickReply.swap() to make the function working.

_x000D_
_x000D_
document.getElementById("div").onload = oQuickReplyswap();_x000D_
function oQuickReplyswap() {_x000D_
alert("Hello World");_x000D_
}
_x000D_
<div id="div"></div>
_x000D_
_x000D_
_x000D_