[whatwg] Scripting Tweaks

Dean Edwards dean at edwards.name
Wed Apr 20 07:50:02 PDT 2005


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




More information about the whatwg mailing list