- From: Jonas Sicking <jonas@sicking.cc>
- Date: Thu, 15 Jan 2009 15:09:18 -0800
On Thu, Jan 15, 2009 at 8:28 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote: > Kartikaya Gupta wrote: >> >> sn = document.createElement( 'script' ); >> sn.setAttribute( 'type', 'text/javascript' ); >> document.body.appendChild( sn ); // this *should* run an empty >> script block and do nothing > > That looks like a bug in the spec to me. Empty scripts with no @src are not > executed when inserted into the DOM, and are executed if they ever become At least in the mozilla implementation, though would be interested what other implementations do. The reason was that I wanted to support the following usage pattern: s = document.createElement('script'); document.body.appendChild(s); s.src = "http://foo/bar"; Note that in IE, you can set the src attribute any number of times and every time it will download and execute the new script, even when the old src value is the same as the new. / Jonas
Received on Thursday, 15 January 2009 15:09:18 UTC