How to automatically combine HTML5 and IP geolocation in Javascript

In this tutorial we demonstrate how to automatically combine HTML5 and IP geolocation and get the best of both worlds to detect visitor position.

Browser geolocation is a useful feature that can provide more accurate results than IP address based geolocation. The drawback is that you cannot use it as a reliable source because it is often unavailable for various reasons such as browser support or user permissions.

dbip.getCurrentPosition is a drop-in replacement for the standard navigator.geolocation.getCurrentPosition method.

It takes the same parameters and returns the same values as its standard couterpart, the difference is that it never fails.

If the visitor has browser geolocation turned off or doesn't allow it before the specified timeout, the coordinates are looked up using their IP address :


Free Basic Core Extended IP to Country IP to City IP to Location IP to ISP IP to Location+ISP

Was this article helpful ? Share it with others by clicking the social media buttons !