View Full Version : what country surfer from?
saldikey
09-03-2002, 04:37 PM
hi, all
i know that at vbscript there is <echo_host> tag that help u to get IP address of surfer...
i am doing site, where i want be able to put some information depending on what country surfer from.
i read js bible but found nothing about it. it should be some way to do it. is anyone knows?:confused:
joh6nn
09-03-2002, 04:59 PM
it can't be done with javascript.
a more reliable way of figuring out what country someone is from, is looking at the language they're using. in Netscape, it's
window.navigator.language
and in IE4+, it's
window.navigator.systemLanguage.
you can match the strings that those properties return, against this page:
http://www.oasis-open.org/cover/iso639a.html
hope that helps.
saldikey
09-03-2002, 05:17 PM
thanx for reply and url of that page(I gotta spend some time there), in my case it will not help. - i am russian in usa using english version OS because its easy for me, but i know a lot people that using OS in their own language with region settings that not always correct.
i just had to explain more details. what i really want to know if its USA surfer or not. i heard that there is ip mask for every country. so if i could catch ip and compare it some mask this will be the way
joh6nn
09-03-2002, 05:32 PM
i've always suspected that there was an IP mask for country, but i've never seen anything to confirm it. and again, using just javascript, there's no way to get the IP. there's also always the problem of people using proxies that hide or change their IP numbers. so it would be just as likely to be inaccurate, as using the language property.
if you find a list of IP masks, let me know.
what part of russia are you from?
joh6nn
09-03-2002, 05:52 PM
here's a start for the IP's:
http://www.iana.org/assignments/ipv4-address-space
saldikey
09-03-2002, 05:58 PM
ok :) it was bad idea
look at this part
128-191/8 Various Registries May 93
192/8 Various Registries - MultiRegional May 93
why i always try to do impossible?:rolleyes:
joh6nn
09-03-2002, 07:00 PM
here's a more complete one. it takes a while to load, and it takes a minute of looking at it, to figure out what it's saying, but it's definitely detailed.
ftp://ftp.apnic.net/pub/apnic/dbase/data/country-ipv4.lst
saldikey
09-03-2002, 08:40 PM
i have another idea: determine by current time at users PC. I mean compare time and date at host with user's machine.- another crazy idea?
let me figure out how to put in script, i will need perl for sure
joh6nn
09-03-2002, 08:46 PM
javascript has a method to determine time zone that a computer is in. how it works, i don't know, but here it is:
dateObject.getTimezoneOffset();
returns the number of minutes difference between GMT, and the local time.
saldikey
09-03-2002, 08:54 PM
Thank you very much :thumbsup:
here is what JS Bible by Danny Goodman says about it:
Accommodating time zones
Understanding the dateObj.getTimezoneOffset() method involves both your
operating system’s time control panel setting and an internationally recognized (in
computerdom, anyway) format for representing dates and times. In the eastern part of
North America, for instance, the eastern standard time zone is five hours earlier
than Greenwich mean time. With the getTimezoneOffset() method producing a
value of minutes’ difference between GMT and the PC’s time zone, the five hours
difference of eastern standard time is rendered as a value of 300 minutes. Offsets to the east of GMT (to the
date line) are expressed as negative values.
mordred
09-03-2002, 08:59 PM
IIRC this method is quite useful because it also reflects a possible summer time change in the numbers of minutes returned - i.e. I'm currently -120 minutes compared to GMT, but I'm in Germany though, which normally is only one hour ahead of GMT. So you have to be aware of this fact if you try to determine the visitors longitude position by this method, saldikey.
And there lies the second problem: Just looking at the timezone could mean that your visitor is in Siberia, China or Australia, so that might not help you that much... ;)
Perhaps you think the other way round: Let the visitor decide on the index page of your site which language/region information he wants to see. Then you leave the decision completely to the user (which makes him happy) and that's also the way most sites of international corporations work.
saldikey
09-03-2002, 09:44 PM
hi2all
could u please check this page www.narhoz.com/Test.html
are u getting correct result?
thanx
saldikey,
Yhea it says North America.
I'm in California. So looks good.
joh6nn
09-04-2002, 01:31 AM
Error: syntax error
Source File: http://www.narhoz.com/Test.html
Line: 11
Source Code:
else {document.write("You are outside of North America")};
it's not running in Moz 1.1, because of the misplaced semi-colon, but i'm expecting that it would give the right results.
saldikey
09-04-2002, 01:36 AM
it maybe sounds stupid. what is a big deal?
i am doing site to be viewed at USA and Russia, the same language and the same content but i don't want bother people in USA with banner ads from Russia and opposite.
so. thanx for your ideas
mordred
09-04-2002, 02:11 AM
"Your are in North America " ... but I ain't. Still in Germany, though I wouldn't mind some vacation. ;)
I believe the problem lies in the logic of this line:
if (yourtime>=300 || yourtime <=460)
looks to me as if that's always a true condition...
saldikey
09-04-2002, 02:29 AM
thanx
&&
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.