Click here to Skip to main content
15,850,103 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    var x = document.getElementById("demo");
    var Latitudevar;
    var Longitudevar;
    function getLocation() {
        if (navigator.geolocation) {
        } else {
            x.innerHTML = "Geolocation is not supported by this browser.";

    function showPosition(position) {

        x.innerHTML = "Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;

        Latitudevar = position.coords.latitude;
        Longitudevar = position.coords.longitude;


    function GetAddress() {

        var lat = Latitudevar;
        var lng = Longitudevar;
        var latlng = new google.maps.LatLng(lat, lng);
        var geocoder = geocoder = new google.maps.Geocoder();
        geocoder.geocode({ 'latLng': latlng }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                   // alert("Location: " + results[1].formatted_address);
                    x.innerHTML = "Area: " + results[1].formatted_address;



Updated 22-Jun-15 4:41am
Thanks7872 22-Jun-15 9:23am    
Why you are posting all your explanation as a solution? Look at bottom of the question, there is a link "Improve question", use it.
hariprashanth11 22-Jun-15 9:25am    
ok thanks buddy ... keep tracking and give me a solution.
Which version of IE?
hariprashanth11 23-Jun-15 1:03am    
IE all the versions.
I have created this fiddle for you. See if this is working or not. It was working for me in IE.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900