Using document.createElement() to test for browser support for an element

Started by Darren Dirt, February 01, 2012, 09:05:28 AM

Previous topic - Next topic

Darren Dirt

I found this to be pretty interesting...

HTML5 has a bunch of new INPUT types, including native calendar popup, but what if your users are using an older browser*? jQuery's datepicker ftw, but we don't want to load the .js files if they're not needed...

http://www.javascriptkit.com/javatutors/createelementcheck2.shtml


(part 1 has a nice detailed explanation about the .createElement technique of testing if the element is supported)




*which, in the case of <input type="date">, means "everything except Opera 9+" ... however since current Chrome supports <input type="range">, the above example could be modified accordingly if you actually want to test this yourself.

_____________________

Strive for progress. Not perfection.
_____________________

Thorin

Quote from: Darren Dirt on February 01, 2012, 09:05:28 AM
new INPUT types

I really like the layout of that site (although the grammar is pretty rough at times).  Clean, good colours and fonts.
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful