15
Apr
2008

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>

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

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

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

logo

Mat's Blog

California Dreaming

Users Status

You are not logged in.

Search

 

Weather

Aktuelles Wetter in Kitzbuhel:


Temperatur: -3 C
UV Index: 0
Luftfeuchte: 100 %
Sichtweite: 10.0 km
Luftdruck: 1019.0 mb
Windstärke: 3 km/h

Weather data provided by weather.com

Get Firefox

Get Firefox!

Currently Reading


William Gibson, Jarreth Merz, Matthias Scherwenikas
Neuromancer, 3 Audio-CDs

Archive

April 2008
Sun
Mon
Tue
Wed
Thu
Fri
Sat
 
 
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
10
11
12
13
14
16
17
18
19
20
21
25
27
28
29
30
 
 
 
 

Recent Updates

das verpasse ich leider......
das verpasse ich leider... http://twitter.com/flog/st atus/998712029
flog - 10. Nov, 21:38
bin schon sehr gespannt!...
bin schon sehr gespannt! bis dann
barbarao - 10. Nov, 15:59
hab mich auch gerade...
hab mich auch gerade angemeldet ;)
barbarao - 26. Aug, 10:57
minute 33 is auch sehr...
minute 33 is auch sehr interessant.
MasterOfDesaster - 7. Jul, 16:00
ja der Vortrag ist sehr...
ja der Vortrag ist sehr nett und zum testen kann man...
niepi - 4. Jul, 13:14
BTW: TrimJunction isn't...
BTW: TrimJunction isn't the Rhino port of Rails which...
robert42 - 27. Jun, 16:59
danke :)
danke :)
matthias - 5. Jun, 08:41
up again...magic ;)
up again...magic ;)
MasterOfDesaster - 3. Jun, 10:43

Status

Online for 1497 days
Last update: 10. Nov, 21:38

Credits

Knallgrau New Media Solutions - Web Agentur für neue Medien

powered by Antville powered by Helma


Creative Commons License

xml version of this page

twoday.net AGB