W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2005

[whatwg] Scripting Tweaks

From: Dean Edwards <dean@edwards.name>
Date: Wed, 20 Apr 2005 15:50:02 +0100
Message-ID: <42666C1A.7050203@edwards.name>
Ian Hickson wrote:
> On Wed, 20 Apr 2005, Dean Edwards wrote:
> 
>>The use case is a web app that submits data to a hidden iframe. This is 
>>common in JSP type backends. The hidden frame then updates the page with 
>>new data. Maybe this is just me working on projects that are designed 
>>wrong! Anyone else encounter this scenario?
> 
> 
> So you'd submit to a hidden <iframe> and then disable the main page?
> 

Yep. The iframe then unlocks the page when submission is complete. 
Forgetting about iframes for a minute. This is analogous to disabling 
the entire application (not the chrome). Most GUI apps have this 
behavior to some degree.

> In past projects of this nature I used to create a new <iframe> each time 
> I submitted something, so there'd be no problem submitting multiple times, 
> it would just update the UI multiple times (and if they shouldn't, then I 
> would prevent the submission by disabling the entry points to submitting).
> 
> More recently I just spawn a new XMLHttpRequest for each submission.
> 

For this particular use case there are now better techniques it's true.

> 
>>I can't think of one off the top of my head but I do find myself using 
>>it. It's certainly handy for passing string references around rather 
>>than object references.
> 
> 
> Wouldn't object references by lighter weight?
> 

Sometimes you want to construct eval code. A string reference is the 
only way to do this. Here is some sample code from IE7 that disables 
unsuccessful form controls on submission:

[code]
elem[i].disabled = true;
setTimeout("document.all." + elem[i].uniqueID + ".disabled=false", 1);
[/code]

To do the same using object references you would have to create a 
closure. The string version is easier. As I say, I found myself using 
this surprisingly often. But then I do write some pretty freaky code... ;-)

-dean
Received on Wednesday, 20 April 2005 07:50:02 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:22 UTC