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
MasterOfDesaster - 16. Apr, 11:26
luckily some people use ie6 and or old machines :(
so i like bubbling much more
http://www.quirksmode.org/js/events_order.html
so i like bubbling much more
http://www.quirksmode.org/js/events_order.html
matthias - 16. Apr, 16:22
danke für den hinweis
fixed forEach (which is Javascript 1.6) to .each() which is prototype.js - know it works in ie6









Trackback URL:
http://www.matsblog.com/stories/4864686/modTrackback