Element.onload
A simple way to add onload event handlers to all HTML elements, using prototype.js
<html>
<head>
<title>Element.onload</title>
<script src="../../lib/prototype-1.6.0.2.js" type="text/javascript"></script>
<script type="text/javascript">
document.observe("dom:loaded", function() {
// call all onload attributes
$$('body *[onload]').each( function(ele) {
eval('(function() {' + ele.getAttribute("onload") + '}).bind(ele)()');
})
});
</script>
</head>
<body>
<h1>Element.onload</h1>
<div onload="alert(this.innerHTML)">Hello</div>
<div onload="alert(this.innerHTML)">World!</div>
</body>
</html>
matthias - 15. Apr, 16:35
2 comments - add comment - 0 trackbacks






