Business Gifts - Debt Consolidation - Payday Loans - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Javascript For City, and State


McDonalds|Chicken|Selects
Dec 21st 2008, 11:04 am
I am looking for a javascript code that will display the state and city of the visitor in text,

example: "Welcome visitor from Los Angles, California"

-thanks

astupidname
Dec 21st 2008, 8:15 pm
Can't be done, don't want it done, and if you ever figure out how to do it, and you do it, we will send the trenchcoats after you. Think about it. Men in trenchcoats and dark shades on your doorstep. Not good. :( :eek:
It is a hideously bad idea, just forget about it.

islandhopper8
Dec 21st 2008, 9:10 pm
Here is some example of code that you can use to do it:

<script language="Javascript" src="http://www.ip2phrase.com/ip2phrase.asp?template=Special welcome to our visitors from <CITY>, <COUNTRY>."></script><br>Powered by <a href="http://www.ip2location.com">IP2Location.com</a>

McDonalds|Chicken|Selects
Dec 21st 2008, 11:10 pm
Can't be done, don't want it done, and if you ever figure out how to do it, and you do it, we will send the trenchcoats after you. Think about it. Men in trenchcoats and dark shades on your doorstep. Not good. :( :eek:
It is a hideously bad idea, just forget about it.

I've seen it done, maybe it wasn't javascript though, because I saw an ad that would show my city and state,
even if I viewed it through a proxy it would say:

"visitor from anonymous proxy"

islandhopper8
Dec 22nd 2008, 9:01 am
It is very easy to do it with code behind. Just check the visitor IP address and use one of the API IP to location services or download an IP database and read the information from your own database.
The same way how I made this image here show visitors IP address and Location (http://findmyipaddress.info/Show_Visitor_ip_address_image.aspx)
I downloaded a comprehensive cvs list that I found on the internet and converted it into a database.

Looks like this :
http://www.findmyipaddress.info/myipaddressimg.aspx

To read the IP address in ASPX vb.net can be done as follows:
Dim ip As String = Request.UserHostAddress

If you need to convert the IP address to number you do that as follows:
Public Function IPAddressToNumber(ByVal IPaddress As String) As Double
Dim arrDec() As String
Dim intResult As Long
If IPaddress = "" Then
IPAddressToNumber = 0
Else
arrDec = IPaddress.Split(".")
intResult = (arrDec(0) * 16777216) + (arrDec(1) * 65536) + (arrDec(2) * 256) + arrDec(3)
IPAddressToNumber = intResult
End If
End Function

Here the example how to read it out of an Access Database:
Public Function ipfetch(ByVal ipAddress As String) As String()
Dim ipnum As Long = IPAddressToNumber(ipAddress)
Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/ip-to-country.mdb;Persist Security Info=False"
Dim cmdDB As String = ""
Dim adapterDB As New OleDbDataAdapter(cmdDB, conn)
Dim DS As New DataSet
Dim country As String = Nothing
Dim flag As String = Nothing
cmdDB = "SELECT country, country2 FROM(Country) WHERE ((([Ip_from])<" & ipnum & ") AND ((IP_To)>=" & ipnum & " ));"
adapterDB.SelectCommand.CommandText = cmdDB
DS.Reset()
adapterDB.Fill(DS)
Dim r As Integer = DS.Tables(0).Rows.Count
If DS.Tables(0).Rows.Count > 0 Then
country = DS.Tables(0).Rows(0).Item("country").ToString()
flag = DS.Tables(0).Rows(0).Item("country2").ToString()
End If
If Not String.IsNullOrEmpty(country) Then
Return ("images\flags\" & flag & ".png" & "," & country).Split(",")
End If
Return "Unknown, , ".Split(",")
End Function

Hope this gets you started.

astupidname
Dec 23rd 2008, 10:05 pm
I figured some smarta$$ would come along and give you what you wanted... shame on him. As I said earlier..
It is a hideously bad idea, just forget about it.
I do apologize if I was/am being somewhat inflammatory.. but I stand by the above quote.
You seriously should read up on web usability and user preferences. The number one thing we don't want you doing is anything that feels like control of our computer or browser. Number two would be anything that has any sort of a "big brother watching" feel to it.
Displaying such type of message (no matter how friendly, nice, or warm and fuzzy) to a visitor breaks number two in a gawdawful way and should not be done. I see a message like that on any site, letting me know that you know where I am, and I will never ever ever come back. Period. Never. You got that? Do you want visitors?
The only circumstance where a message such as that would be somewhat acceptable, is after logging in to a members/account area, and even then only if I already gave you my address when signing up. And that should be limited only to sites that involve money.. i.e. paid membership or shopping purchase accounts or other financial accounts.
So, to wrap up, it really is in your best interest to rethink the idea. After all, WE KNOW WHERE YOU LIVE. Feels great don't it? Just the kind of web experience everybody dreams of.....

islandhopper8
Dec 26th 2008, 9:04 am
I understand your point of view and I agree that some people might not appreciate it, but there will be people who will like it. As with everything in life, you have two extremes and in between you have a whole ranges of different opinions. So yes will will loose some, but you also will win some as everyone has a different opinion about web experience. I respect you believe that you will never come back to a site that shows your information and is open about it, while there are many sites that even log more and you will happily return every time, just because they are doing it "out of sight". Fact is majority of the sites are logging some kind of information about you. Dont you think this forum is not logging your IP address???

To me showing your IP address and city is not a big thing, as all your actions are somewhere logged on the internet. A lot of people dont have a clue what kind of information is being logged when they are on the internet. Therefor I think it is a good thing to show some awareness to the visitors that there is a lot of information they dont realize is already know about them. By NOT showing it does not take away the fact that all this information is still being logged!

It is even used by big companies such as dell, where it shows you your country and at the same time, where you can contact the closest dealer. It helps those sites to achive better support to their visitors and provide a better visitor experience. To me it is a great feature, when you come to a site and you are looking for localized info, they picked up your country, city and provide that information to you, so you dont even have to look for it.

Like with everything there is the good, the bad and the ugly.

By knowing the country and city, you still are far from you actual address :)

astupidname
Dec 27th 2008, 1:31 am
For: islandhopper8
I do agree with a lot of what you say in your most recent post (#7). This subject certainly is an interesting talking point to me..
I understand your point of view and I agree that some people might not appreciate it
Thanks..
while there are many sites that even log more and you will happily return every time, just because they are doing it "out of sight". Fact is majority of the sites are logging some kind of information about you
While that may be true in some cases.., unexpected, unhelpful blatantness is creepy to not just me...
A lot of people dont have a clue what kind of information is being logged when they are on the internet

By NOT showing it does not take away the fact that all this information is still being logged!

If we can't see it (even though we do suspect it), it's not nearly as scary as being able to blatantly see it or have our noses rubbed in it purposely (yet, for no real, helpful, purpose)... Ignorance is bliss, afterall!

It is even used by big companies such as dell, where it shows you your country and at the same time, where you can contact the closest dealer. It helps those sites to achive better support to their visitors
Agreed, that is certainly one accepted use, as it is being helpful, yet un-alarming. Another example is Yahoo. On yahoo.com, their news categories, you can select "Local" and then it will also show a link that says "More [your town and state here] news". That is both subtle and helpful (subtle because I had to click on "local" first to display it, and helpful because then there is being help offered which is location specific).

example: "Welcome visitor from Los Angles, California"

I guess my whole point really boils down to acceptable use of such ability. While it's possible the OP may have more subtle, helpful, purposes in mind for the above example (hopefully), the above example is still totally unacceptable use IMO. You do, in a way, make a point that there are better, more subtle, and helpful uses for this ability, and that I do agree with. So to anyone reading this, I would say if you intend to utilize such tools be extremely sensitive to the manner in which you let the user know what you know about them when displaying it on-screen. That said, it is well known that you certainly should be totally blatant about it in your Terms of Service and/or Privacy Policy.
Happy holidays to you all!

bhagwat_banna
Jan 1st 2009, 8:57 pm
but i think it is the server ip address..

which we used for internet connection.

how can we find out each computer ip which is using same network for net.

dimitar christoff
Jan 2nd 2009, 10:56 am
oh geolocation is also very handy, especially in advertising / marketing that is targeted to a specific audience. For instance, you run a recruitment agency and have a series of PPC adverts with extracts of such jobs on a technical web development blog... it makes sense showing ME an advert for a web developer in London and not a random advert from Manchester.

Same logic is being applied by Adult Friend Finder - if I really wanted to be meeting "with women in your area tonight", then their geolocational adverts are just the ticket to get me started. :D

nothing too "big brothery" about it, on the contrary, I think people need to start realising that anonymity on the web is a myth and certain actions can have repercussions.