Using Firefox’s Geolocation API
One interesting aspect of web development is Geolocation; where is your user viewing your website from? You can base your language locale on that data or show certain products in your store based on the user's location. Let's examine how you can use Geolocation within Firefox to get location details down to the street!
Detecting Browser Geolocation Capabilities
if("geolocation" in navigator) {
//w00t!
}
else {
alert("No soup for you! Your browser does not support this feature");
}
They key to detecting Geolocation within your browser is the navigator.geolocation object.
Querying For Geolocation Information
if("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(function(position) {
alert("Your lat-long is: " + position.coords.latitude + " / " + position.coords.longitude);
alert("You live in " + position.address.city + ", " + position.address.region)
});
}
The navigator.geolocation.getCurrentPosition method is the driving force behind retrieving location details. Once you call this method (providing it a function which will execute if your request is successful), the browser will ask the user if they will allow you to retrieve their location information:
When the user allows the website to retrieve their location information, Firefox fetches the information, providing you a position object with two very useful attributes: position.coords and position.address. position.coords gives you latitude and longitude while position.address gives you streetNumber, street, premises, city, county, region, country, countryCode, and postalCode. Firefox may even take a picture of your user through his/her window soon. (Editor's note: I completely made that up)
Of course most of this functionality is only available within Firefox. Safari will retrieve the user's latitude and longitude but that's the extent of WebKit's support. I look forward to bigger and better things from the W3C's Geolocation API in the future!

It will be cool when this becomes a viable option on sites (when more browsers support it)
@Dan: I’m going to write a book about the history of the WWW and that’s going to be the title.
Latitude and Longitude work fine on Opera 10.60.
Kinda scary how easy it is to get your location…
Wow, this creeps me out David! You always seem to amaze me… :-O
A feature like this could be very handy for all those annoyed people who don’t like filling in address forms. Does this always work, even with firewalls/DNS/hotspots/ripping internet from your neighbours?
Hi…I implemented W3C Geo location within MooGeo and you can view in action some demos: http://thinkphp.ro/apps/js-hacks/MooGeo/
Hi…I implemented W3C Geo location within MooGeo and you can view in action some demos: http://is.gd/d8Kgm
Lat and Long seems to work in Chrome 6 for me.
It’s really interesting and cool but it depends a lot on your ISP, for example, I live in Vicenza, Italy, our company uses Fastweb as ISP, and geolocation responds that I stay in Modena, a city in an other region!!!!
This worked great on android’s webkit browser. Also tested in FF and Chrome and worked nice.
Can you update this to use ‘geolocation’ in navigator ?
Here is why: https://github.com/Modernizr/Modernizr/blob/633a5ac/modernizr.js#L478-490
Updated as requested!