Consider investigating the HTML5 geolocation API.
HTML5 Demo: geolocation[
^]
[W3 Schools] HTML5 Geolocation[
^]
This method requires user permission to work, however it is often far more useful than IP geolocation because if a device (eg, a mobile phone) supports GPS location, than it will use GPS. If GPS is not supported, the browser automatically falls back to IP geolocation.