最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

geolocation - How to display current country and city in HTML with JavaScript - Stack Overflow

programmeradmin3浏览0评论

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/

发布评论

评论列表(0)

  1. 暂无评论