Pinpoint Users' Locations via JavaScript and the Web's Geolocation API

Become An Insider

Sign up now and get FREE access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content. Learn more.

You've probably visited websites where you've been asked to share your location; if you agree, the site determines where you are and then typically gives you extra functionality such as directions or local weather.

Sites can pinpoint your location (if you give permission) by implementing the Geolocation API, a standard adopted by the World Wide Web Consortium that's available on recent versions of platforms including IE, Firefox, Safari, Chrome, Opera, iOS and Android.

In this PDF download, you'll see how just a few lines of JavaScript are needed to discover a user's location. (This PDF is excerpted with permission from the publisher, Wiley, from JavaScript & jQuery: Interactive front-end Web development by John Duckett. Copyright 2014 all rights reserved.

To continue reading this article register now

Notice to our Readers
We're now using social media to take your comments and feedback. Learn more about this here.