Monday, July 8, 2013

Get current location using API

<html>
<title>Get Current Location</title>
<head>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script language="JavaScript" type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript">
 jQuery(function() {
     jQuery('#country_code').text(geoip_country_code());
     jQuery('#country_name').text(geoip_country_name());
     jQuery('#city').text(geoip_city());
     jQuery('#region_code').text(geoip_region());
     jQuery('#region_name').text(geoip_region_name());
     jQuery('#latitude').text(geoip_latitude());
     jQuery('#longitude').text(geoip_longitude());
});
</script>
<head>
<body>
    <div>
          <div>
                  Country Code=<b id="country_code"></b>
           </div>
         <div>
                  Country Name=<b id="country_name"></b>
           </div>
          <div>
                  City= <b id="city"></b>
           </div>
          <div>
                  Region Code=<b id="region_code"></b>
           </div>
           <div>
                  Region Name:<b id="region_name"></b>
           </div>
          <div>
                  Current Latitude=<b id="latitude"></b>
           </div>
           <div>
                  Current Longitude=<b id="longitude"></b>
           </div>

    </div>
</body>
</html>

No comments:

Post a Comment