HTML and CSS Reference
In-Depth Information
for representing complex mathematical and scientific equations. Currently only Firefox 3.6 renders
inline SVG, and only after a special HTML5 parser has been enabled.
Advanced form controls and functionality are among the most tantalizing HTML5 highlights. A
wide range of new input types — such as e-mail, number, and telephone — combined with valida-
tion and some advanced controls (slider and calendar among others) make the form enhancements
extremely desirable. Sadly, only Opera has seen fit to fully implement the specification to a signifi-
cant degree. Hopefully, the other browsers will follow suit sooner rather than later.
deTerMininG wHaa a
works dyna
d yna
LL y
As browsers leap-frog over one another to offer more advanced technology than their competitors,
a new philosophy has taken hold among web designers. Rather than wait until all users' browsers
have reached a desirable level, designers have looked for a way to provide an advantage to those
users with more advanced browsers while not detracting from the message for those who use older
web viewing programs. This approach is known as progressive enhancement .
To render the page differently for different browsers, it's necessary to detect whether the more advanced
features are available on a per-browser basis. Various JavaScript functions can be used for this purpose
and to insert the necessary code or text into a page depending on the detection outcome.
Look at an example concerning one of the more exotic HTML5 enhancements, geolocation.
Geolocation is a new property added to the Document Object Model in HTML5 that returns the
physical location of a site visitor's computer. Or rather, the location of the visitor's IP address,
which may be broadcasting from the nearest Internet node or cell tower. Geolocation is a function
with a great number of applications: Imagine searching for “Italian restaurant” and a list of the
nearest five is returned. Geolocation functionality is available in Firefox 3.5+, Safari 5+, Chrome
5+, and Opera 10+, but not Internet Explorer.
To determine whether a browser supports the geolocation property, all that's needed is a simple
JavaScript call, like this:
if (navigator.geolocation) {
// code if geolocation supported goes here
} else {
// code if geolocation not supported goes here
I'm sure there are a great many among you — myself included — who, upon
learning of the geolocation functionality immediately think, “But what if I don't
want my location found?” According to the current HTML5 specifications, geo-
location is intended to be opt-in and not automatic. In other words, browsers
must ask the site visitor's permission before detecting his or her position. Firefox
opens an info bar that asks if you'd like to share your location and other brows-
ers have a similar apparatus in place.
Search WWH ::

Custom Search