[whatwg] Scripting Tweaks

On Wed, 20 Apr 2005, Dean Edwards wrote:
> > 
> > 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.

Most GUI applications don't have the possibility of the network dying and 
never re-enabling the page. :-)


> > > 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... 
> ;-)

I beg to differ:

   elem[i].disabled = true;
   setTimeout(function () { elem[i].disabled = false }, 1);

That looks a lot easier than the eval() to me. And shorter. And it will 
have syntax errors caught at compile time.

Is there another use case? :-)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 20 April 2005 07:52:57 UTC