0

Is there a JavaScript script that determines the geographical location of the visitor? I need one to determine that and depending on there location run 1 of about 5 different JavaScript scripts. How do i do this? Does someone know were i can can a script to do this or could someone write one. I am not very good at Javascript so i cant write my own

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by digital-ether
0

That was what i was aiming for something that did it by ip address. I will be using php but is this possible without php? This script still does not do what i want though.

0

yes, you can use ajax, query the webservice with ajax, when you get the location information in your xmldocument object. you can run your javascript code accordingly.

0

Is there a JavaScript script that determines the geographical location of the visitor? I need one to determine that and depending on there location run 1 of about 5 different JavaScript scripts. How do i do this? Does someone know were i can can a script to do this or could someone write one. I am not very good at Javascript so i cant write my own

Mozilla is working on getting location into the browser:
http://labs.mozilla.com/2008/10/introducing-geode/

You'll need a service that does the location guessing for you at the moment.

Loki is available in JS: http://loki.com/how

You can also use an IP geocoding service such as:
http://api.hostip.info/get_xml.php?ip=12.215.42.19

Then use a proxy to get that information via javascript.
eg:
http://jsonproxy.appspot.com/proxy?url=http://api.hostip.info/get_xml.php%3Fip%3D12.215.42.19%26position%3Dtrue&callback=getLocation

or using library that does this automatically:
http://rss-javascript.googlecode.com/svn/trunk/rssclient.js

eg:

client = new RSSClient();
client.getURL('http://api.hostip.info/get_xml.php?ip=12.215.42.19', function(xml) {
// get the location from the returned xml document
});
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.