W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2006

[whatwg] Detecting Web Forms for future proof scripts?

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Tue, 03 Oct 2006 09:57:34 +1000
Message-ID: <4521A76E.5000401@lachy.id.au>
Hallvord R M Steen wrote:
> On 02/10/06, Ric Hardacre <ric at hardacre.org> wrote:
>>  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?
> 
> What about this attempt?
> 
> http://www.hallvord.com/opera/demo/wf2-datalist.htm

It's easier to just check for the interface.

if (window.HTMLDataListElement) {
   // datalist is supported.
}

However, thanks to a bug in Opera 9, you have do this:

if (window.HTMLDataListElement || window.HTMLDatalistElement) {
   // datalist is supported.
}

The first is what the spec defined, the second is what Opera initially 
implemented, but it's being fixed.

-- 
Lachlan Hunt
http://lachy.id.au/
Received on Monday, 2 October 2006 16:57:34 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:48 UTC