Chrome and Firefox have HTML Geolocation implemented.
My question is: how does it work? Do they have a Database locally and get the information from the provider the
Try this in Chrome.
Here is your answer. Click on "How Google Chrome determines your location".
From that page:
If you allow Google Chrome to share your location with a site, the browser will send local network information to Google Location Services to get an estimate of your location. The browser can then share your location with the requesting site. The local network information used by Google Location Services to estimate your location includes information about visible WiFi access points, including their signal strength; information about your local router; your computer's IP address. The accuracy and coverage of Google Location Services will vary by location.
Google Chrome saves your location information so that it can be easily retrieved. This information is periodically updated; the frequency of updates depends on changes to your local network information.
Also, I believe that Google Location Services contains a database built from data collected by Google Street View vans as they match locations with WiFi signals from routers (or at least used to).
As for the database (Google Location Services), this SO question will help you access it.