W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2010

[whatwg] (deferred) script tags with document.write built in

From: Brett Zamir <brettz9@yahoo.com>
Date: Sat, 24 Jul 2010 21:43:35 +0800
Message-ID: <4C4AEE07.9040004@yahoo.com>
  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>
Received on Saturday, 24 July 2010 06:43:35 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:25 UTC