[whatwg] Detecting Web Forms for future proof scripts?

On Mon, 2 Oct 2006, Ric Hardacre wrote:
>
> [scriplets] need to check that they're running on a compatible scripting 
> engine, just checking for the existence of document.getElementById is 
> the simple way (If there are better ways then I'm always open to 
> learning). But I'm presented with an issue, suppose for example I wanted 
> to emulate the datalist element for a text box. I can use the DOM and 
> some on-the fly CSS to build a Javascript emulated datalist, but how 
> would one go about ensuring that if/when it encounters a browser that 
> can handle the datalist that it does not execute? This is probably quite 
> an open question and yes I'm aware of the 
> embedding-a-select-inside-the-datalist solution to this particular 
> example, but the general question remains: How to script WF2 
> functionality for current browsers in a way that both degrades AND 
> yields to the UA when it can handle the functionality natively?

For <datalist>, you could just check the class name of a <datalist> 
element, or check to see if the <input> element has a "list" DOM 
attribute, as in "if ('list' in inputElement)".

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

Received on Thursday, 23 October 2008 06:53:39 UTC