How to Get Current Location (Country, State, and City) Name Using Java Script


JavaScript Window Location. location. href returns the href (URL) of the current page. location.


This example shows how to customize the PowerShell prompt. The function that defines the prompt includes a Get-Location command, which is run whenever the prompt appears in the console.
The format of the default PowerShell prompt is defined by a special function named prompt. You can change the prompt in your console by creating a new function named prompt.


  1. <script>
                $.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?')
                   .done(function (location) {
                       $('#textboxid').val(location.city);
                   });
            </script>


Note: On page load browser asks you for access your location so once you need to allow it.

Post a Comment

0 Comments