Righteous Wrath Online Community

General => Tech Chat => Topic started by: Darren Dirt on February 01, 2012, 09:05:28 AM

Title: Using document.createElement() to test for browser support for an element
Post by: Darren Dirt on February 01, 2012, 09:05:28 AM
I found this to be pretty interesting...

HTML5 has a bunch of new INPUT types (http://html5tutorial.info/html5-webform2.php), including native calendar popup, but what if your users are using an older browser*? jQuery's datepicker ftw (http://docs.jquery.com/UI/Datepicker), but we don't want to load the .js files if they're not needed...

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


(part 1 (http://www.javascriptkit.com/javatutors/createelementcheck.shtml) 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" (http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_input_type_range)>, the above example could be modified accordingly if you actually want to test this yourself.

Title: Re: Using document.createElement() to test for browser support for an element
Post by: Thorin on February 01, 2012, 10:24:04 AM
Quote from: Darren Dirt on February 01, 2012, 09:05:28 AM
new INPUT types (http://html5tutorial.info/html5-webform2.php)

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