[whatwg] (deferred) script tags with document.write built in
Brett Zamir
brettz9 at yahoo.com
Sat Jul 24 06:43:35 PDT 2010
Might there be a way that <script/> tags could add an attribute which
combined the meaning of both "defer" and "document.write", whereby the
last statement was evaluated to a string, but ideally treated, as far as
the DOM, with the string being parsed and replacing the containing
script node.
For example:
<script write>
'<span onmouseover="alert(\''+(new Date())+'\')">I\'ve got the date</span>'
</script>
If E4X were supported (since we otherwise lamentably have no PHP-style
HEREDOC syntax in JavaScript to minimize the few warts above), allowing
this to be used could be especially convenient:
<script write>
<span onmouseover="alert(new Date())">I've got the date</span>
</script>
(Maybe even a new <write/> tag could be made to do this exclusively and
more succinctly.)
I chose "defer" as the default behavior so as to be XHTML-friendly, to
allow convenient reference by default to other DOM elements without the
need for adding a listener, and the more appealing default behavior of
not blocking other content from appearing.
Since it doesn't seem that XQuery support will be making it into
browsers anytime soon, it would be nice to be able to emulate its clean
template-friendly declarative style, dropping the need to find and
append to elements, etc..
Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100724/d81f7d8b/attachment-0001.htm>
More information about the whatwg
mailing list