Forum Moderators: open

Message Too Old, No Replies

finding the computer location

using js to guess the users location

         

topr8

12:52 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



sometime last year there was a thread here about using js to test the site visitors location settings on their computer.

... for the purpose of guessing the users location, eg. if the user has their language setting to English UK, it is likely (although not certain of course) that they are in the uk, likewise with ENglish US and so on.

i can't find it, any suggestions, i need this for a site where it is not practicle to get the visitor location from the ip address.

orion_rus

3:36 pm on Jan 10, 2005 (gmt 0)

10+ Year Member



I know a way how it making in PHP, it have a function $_SERVER, but i don't know how determining jscripts IP addresses. If u didn't find a way try to ask about it in PHP forum good luck to you)

jbot

5:17 pm on Jan 10, 2005 (gmt 0)

10+ Year Member



JS can't get the user's IP address at all. to get the user's language setting, try this alert(navigator.language);

topr8

5:40 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>>alert(navigator.language);

yes this will give language, english will come up as "en"
but i want to tell if the language setting is english UK or english US

Bernard Marx

8:03 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's the results of a quick test.
My IP address (and system language) is Swedish, but my browser is set to UK English.

[pre]
Firefox
navigator.language = en-GB
IE6
navigator.userLanguage = en-gb
[/pre]

So it looks like you need to use different properties across browsers, and use a case-insensitive match.

topr8

9:21 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



great thanks, i'll play about with it!