Javascript For City, and State

Discussion in 'JavaScript' started by McDonalds|Chicken|Selects, Dec 21, 2008.

  1. #1
    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
     
  2. astupidname

    astupidname Peon

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    astupidname, Dec 21, 2008 IP
  3. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #3
    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>
    Code (markup):
     
    islandhopper8, Dec 21, 2008 IP
  4. McDonalds|Chicken|Selects

    McDonalds|Chicken|Selects Peon

    Messages:
    58
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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"
     
  5. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #5
    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
    I downloaded a comprehensive cvs list that I found on the internet and converted it into a database.

    Looks like this :
    [​IMG]

    To read the IP address in ASPX vb.net can be done as follows:
    Dim ip As String = Request.UserHostAddress
    Code (markup):
    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
    Code (markup):
    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
    Code (markup):
    Hope this gets you started.
     
    islandhopper8, Dec 22, 2008 IP
  6. astupidname

    astupidname Peon

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I figured some smarta$$ would come along and give you what you wanted... shame on him. As I said earlier..
    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.....
     
    astupidname, Dec 23, 2008 IP
  7. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #7
    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 :)
     
    islandhopper8, Dec 26, 2008 IP
  8. astupidname

    astupidname Peon

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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..
    Thanks..
    While that may be true in some cases.., unexpected, unhelpful blatantness is creepy to not just me...
    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!

    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).

    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!
     
    astupidname, Dec 27, 2008 IP
  9. bhagwat_banna

    bhagwat_banna Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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.
     
    bhagwat_banna, Jan 1, 2009 IP
  10. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #10
    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.
     
    dimitar christoff, Jan 2, 2009 IP