admin管理员组

文章数量:1431420

I am looking for JavaScript which gives me the ability to display City and Country on my application.

Like in image below:

I tried many different solutions, through geolocation, and etc., Doesn't display anything, somebody know how to find right working script, because even here I found some solutions, but doesn't display anything!

One of the examples below! Will appreciate any help!

Thanks in advance

<html>
<head>
<script language="JavaScript" src=".JavaScript"></script>
<script language="JavaScript">
var city = geoip_city();
var country = geoip_country_name();
</script>
</head>
<body>
You are from <script>document.write(city)</script>, <script>document.write(country)</script>.
</body>
</html>

I am looking for JavaScript which gives me the ability to display City and Country on my application.

Like in image below:

I tried many different solutions, through geolocation, and etc., Doesn't display anything, somebody know how to find right working script, because even here I found some solutions, but doesn't display anything!

One of the examples below! Will appreciate any help!

Thanks in advance

<html>
<head>
<script language="JavaScript" src="http://j.maxmind./app/geoip.JavaScript"></script>
<script language="JavaScript">
var city = geoip_city();
var country = geoip_country_name();
</script>
</head>
<body>
You are from <script>document.write(city)</script>, <script>document.write(country)</script>.
</body>
</html>
Share Improve this question edited Feb 20, 2013 at 14:11 Joachim Sauer 309k59 gold badges567 silver badges622 bronze badges asked Feb 20, 2013 at 12:47 Aleksandrs KrasnovskisAleksandrs Krasnovskis 751 gold badge2 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

You need to use API for this.

Check this, see if it helps you

http://www.jquery4u./api-calls/geolocation-jquery-api-geoplugin/

本文标签: geolocationHow to display current country and city in HTML with JavaScriptStack Overflow