I would like to know how geolocation works in a web browser like Google Chrome or Firefox?
I can access this web site http://html5demos.com/geo and when I allow the browser to send my location, it shows my current location.
But when I send that URL to my friends to test it, it doesn’t work for all of them. How does geolocation work and how do I implement it to get the correct location?
Re how it works: the Wikipedia article discusses several techniques (IP address location, cellphone and WiFi triangulation, GPS).
The HTML5 implementations require both browser support (FF 3.6, Opera 10.60, Chrome 4? 5?, IE maybe some day) and user consent before the geolocation data are retrieved.
As to how to implement it, the code of the demo you link to seems to be under the MIT License which basically says “you can do whatever, as long as you keep the resulting code under the license”; so you could take that code as a base to build on.