Simon Willison’s Weblog

Subscribe

3 items tagged “domscripting”

2022

HTML event handler attributes: down the rabbit hole (via) onclick="myfunction(event)" is an idiom for passing the click event to a function - but how does it work? It turns out the answer is buried deep in the HTML spec - the browser wraps that string of code in a function(event) { ... that string ... } function and makes the event available to its local scope that way.

# 26th April 2022, 8:35 pm / domscripting, html, javascript

2007

DOMContentLoaded for IE, Safari, everything, without document.write. Stuart has taken Hedger’s recent IE technique, combined it with the others and compressed it in to a short-as-possible code snippet that you can paste in to your scripts without having to include the whole of jQuery/YUI/Dojo/Prototype.

# 26th September 2007, 12:19 pm / documentwrite, domscripting, ie, javascript, ondomready, safari, stuart-langridge, unobtrusivejavascript

IEContentLoaded. An alternative method of detecting DOMContentLoaded on IE; works by polling until the doScroll() method on an unattached element stops throwing errors.

# 24th September 2007, 12:10 pm / domcontentloaded, domscripting, hedgerwang, ie, iecontentloaded, javascript, unobtrusivejavascript