<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: dom-scripting</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/dom-scripting.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2022-04-26T20:35:08+00:00</updated><author><name>Simon Willison</name></author><entry><title>HTML event handler attributes: down the rabbit hole</title><link href="https://simonwillison.net/2022/Apr/26/html-event-handler-attributes/#atom-tag" rel="alternate"/><published>2022-04-26T20:35:08+00:00</published><updated>2022-04-26T20:35:08+00:00</updated><id>https://simonwillison.net/2022/Apr/26/html-event-handler-attributes/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://datastation.multiprocess.io/blog/2022-04-26-event-handler-attributes.html"&gt;HTML event handler attributes: down the rabbit hole&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;code&gt;onclick="myfunction(event)"&lt;/code&gt; 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 &lt;code&gt;function(event) { ... that string ... }&lt;/code&gt; function and makes the event available to its local scope that way.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/phil_eaton/status/1519048613464268804"&gt;@phil_eaton&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/dom-scripting"&gt;dom-scripting&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/html"&gt;html&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;&lt;/p&gt;



</summary><category term="dom-scripting"/><category term="html"/><category term="javascript"/></entry><entry><title>DOMContentLoaded for IE, Safari, everything, without document.write</title><link href="https://simonwillison.net/2007/Sep/26/sil/#atom-tag" rel="alternate"/><published>2007-09-26T12:19:07+00:00</published><updated>2007-09-26T12:19:07+00:00</updated><id>https://simonwillison.net/2007/Sep/26/sil/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.kryogenix.org/days/2007/09/26/shortloaded"&gt;DOMContentLoaded for IE, Safari, everything, without document.write&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/documentwrite"&gt;documentwrite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dom-scripting"&gt;dom-scripting&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/internet-explorer"&gt;internet-explorer&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ondomready"&gt;ondomready&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/safari"&gt;safari&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/stuart-langridge"&gt;stuart-langridge&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/unobtrusive-javascript"&gt;unobtrusive-javascript&lt;/a&gt;&lt;/p&gt;



</summary><category term="documentwrite"/><category term="dom-scripting"/><category term="internet-explorer"/><category term="javascript"/><category term="ondomready"/><category term="safari"/><category term="stuart-langridge"/><category term="unobtrusive-javascript"/></entry><entry><title>IEContentLoaded</title><link href="https://simonwillison.net/2007/Sep/24/iecontentloaded/#atom-tag" rel="alternate"/><published>2007-09-24T12:10:02+00:00</published><updated>2007-09-24T12:10:02+00:00</updated><id>https://simonwillison.net/2007/Sep/24/iecontentloaded/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.hedgerwow.com/360/dhtml/ie-dom-ondocumentready.html"&gt;IEContentLoaded&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
An alternative method of detecting DOMContentLoaded on IE; works by polling until the doScroll() method on an unattached element stops throwing errors.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/domcontentloaded"&gt;domcontentloaded&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dom-scripting"&gt;dom-scripting&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/hedger-wang"&gt;hedger-wang&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/iecontentloaded"&gt;iecontentloaded&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/internet-explorer"&gt;internet-explorer&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/unobtrusive-javascript"&gt;unobtrusive-javascript&lt;/a&gt;&lt;/p&gt;



</summary><category term="domcontentloaded"/><category term="dom-scripting"/><category term="hedger-wang"/><category term="iecontentloaded"/><category term="internet-explorer"/><category term="javascript"/><category term="unobtrusive-javascript"/></entry></feed>