Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html>
- <head>
- <title>Get web visitor's location</title>
- <meta name="robots" value="none" />
- </head>
- <body>
- <div id="yourinfo"></div>
- <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAp04yNttlQq-7b4aZI_jL5hQYPm-xtd00hTQOC0OXpAMO40FHAxQMnH50uBbWoKVHwgpklyirDEregg"></script>
- <script type="text/javascript">
- if(google.loader.ClientLocation)
- {
- visitor_lat = google.loader.ClientLocation.latitude;
- visitor_lon = google.loader.ClientLocation.longitude;
- visitor_city = google.loader.ClientLocation.address.city;
- visitor_region = google.loader.ClientLocation.address.region;
- visitor_country = google.loader.ClientLocation.address.country;
- visitor_countrycode = google.loader.ClientLocation.address.country_code;
- document.getElementById('yourinfo').innerHTML = '<p>Lat/Lon: ' + visitor_lat + ' / ' + visitor_lon + '</p><p>Location: ' + visitor_city + ', ' + visitor_region + ', ' + visitor_country + ' (' + visitor_countrycode + ')</p>';
- }
- else
- {
- document.getElementById('yourinfo').innerHTML = '<p>Whoops!</p>';
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement