Grab IP Address with JavaScript

Discussion in 'ASP General' started by Larry R. Baker, Nov 6, 2003.

  1. Is it possible to grab a client side IP Address using JavaScript in an htm
    page? I have a web page hosted on a non-ASP server and I want a piece of
    code in JavaScript to grab the IP address of the client and send it to a web
    page on another server. The other page will be ASP.

    I need this for both Netscape and IE browsers.

    Any ideas?
    Larry R. Baker, Nov 6, 2003
    #1
    1. Advertising

  2. Larry R. Baker

    Ray at Guest

    Personally, I don't know. Try asking in a client-side group such as
    ..scripting.jscript.

    Ray at work

    "Larry R. Baker" <> wrote in message
    news:%...
    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.
    >
    > I need this for both Netscape and IE browsers.
    >
    > Any ideas?
    >
    >
    Ray at, Nov 6, 2003
    #2
    1. Advertising

  3. Larry R. Baker

    Randy Rahbar Guest

    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.


    Off topic, but yes, it's possible but you need more than Javascript. We do
    it here using a Java Applet. We grab the IP with the trusted applet, then
    using Javascript we write it to a cookie.
    Randy Rahbar, Nov 6, 2003
    #3
  4. Larry R. Baker

    Ray at Guest

    The server that's hosting the asp page can get the IP address from the
    request.servervariables("remote_addr"). Of course, if the client machine is
    behind a firewall, the client-side resolved IP would be different. But
    unless that matters, let the server do it.

    Ray at work

    "Larry R. Baker" <> wrote in message
    news:%...
    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.
    >
    > I need this for both Netscape and IE browsers.
    >
    > Any ideas?
    >
    >
    Ray at, Nov 6, 2003
    #4
  5. Larry R. Baker

    ljb Guest

    I tried the following client side but it didn't seem 100% reliable. Seems
    not everyone has Winsock installed.

    strIP = CreateObject("MSWinsock.Winsock").LocalIP

    If this thread moves to another group I don't want to lose track since I
    haven't solved the problem yet.

    LJB
    ljb, Nov 6, 2003
    #5
  6. Hey guys sorry if this is off topic, I theorized that since I was sending to
    ASP that it would be on target.

    Again I apologize.

    Larry

    I will repost in the other group.

    "Larry R. Baker" <> wrote in message
    news:%...
    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.
    >
    > I need this for both Netscape and IE browsers.
    >
    > Any ideas?
    >
    >
    Larry R. Baker, Nov 6, 2003
    #6
  7. Hey guys thanks again, the consensus is that the server has to handle this
    and not the client side. I had hoped to avoid this in order to cut down on
    processing overhead but that's life.

    Larry


    "Larry R. Baker" <> wrote in message
    news:%...
    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.
    >
    > I need this for both Netscape and IE browsers.
    >
    > Any ideas?
    >
    >
    Larry R. Baker, Nov 7, 2003
    #7
  8. Larry R. Baker

    Ray at Guest

    Request.ServerVariables("REMOTE_ADDR") will return the IP that the http
    request comes from. This is not necessarily the primary IP of the primary
    NIC in the computer with the browser. It could be a firewall, a proxy
    server, a router, etc., but this may not matter.

    ip.asp:

    <%
    Response.Write "Your IP address is " &
    Request.ServerVariables("REMOTE_ADDR")
    %>


    Ray at home

    "Larry R. Baker" <> wrote in message
    news:...
    > Hey guys thanks again, the consensus is that the server has to handle this
    > and not the client side. I had hoped to avoid this in order to cut down on
    > processing overhead but that's life.
    >
    > Larry
    >
    >
    > "Larry R. Baker" <> wrote in message
    > news:%...
    > > Is it possible to grab a client side IP Address using JavaScript in an

    htm
    > > page? I have a web page hosted on a non-ASP server and I want a piece of
    > > code in JavaScript to grab the IP address of the client and send it to a

    > web
    > > page on another server. The other page will be ASP.
    > >
    > > I need this for both Netscape and IE browsers.
    > >
    > > Any ideas?
    > >
    > >

    >
    >
    Ray at, Nov 7, 2003
    #8
  9. Larry R. Baker

    Roland Hall Guest

    If you user has disabled scripting, you'll cut down on the client-side
    processing too.

    "Larry R. Baker" <> wrote in message
    news:...
    Hey guys thanks again, the consensus is that the server has to handle this
    and not the client side. I had hoped to avoid this in order to cut down on
    processing overhead but that's life.

    Larry


    "Larry R. Baker" <> wrote in message
    news:%...
    > Is it possible to grab a client side IP Address using JavaScript in an htm
    > page? I have a web page hosted on a non-ASP server and I want a piece of
    > code in JavaScript to grab the IP address of the client and send it to a

    web
    > page on another server. The other page will be ASP.
    >
    > I need this for both Netscape and IE browsers.
    >
    > Any ideas?
    >
    >
    Roland Hall, Nov 8, 2003
    #9
  10. Larry R. Baker

    Bob - NoSpam Guest

    "Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
    news:%...
    > > Is it possible to grab a client side IP Address using JavaScript in an

    htm
    > > page? I have a web page hosted on a non-ASP server and I want a piece of
    > > code in JavaScript to grab the IP address of the client and send it to a

    > web
    > > page on another server. The other page will be ASP.

    >
    > Off topic, but yes, it's possible but you need more than Javascript. We

    do
    > it here using a Java Applet.


    >>We grab the IP with the trusted applet, then using Javascript we write it

    to a cookie.
    Randy could you point me to a link on creating cookies? I need to create a
    cookie for time and visit tracking, and I am clueless on how to create
    cookie let alone use them.

    BOB
    Bob - NoSpam, Nov 9, 2003
    #10
  11. Larry R. Baker

    Randy Rahbar Guest

    > Randy could you point me to a link on creating cookies? I need to create a
    > cookie for time and visit tracking, and I am clueless on how to create
    > cookie let alone use them.


    To write the cookie using server-side vbscript:
    Response.Cookie("myCookie") = "This cookie is good!"

    Now to read the cookie using server-side vbscript:
    myVariable = Response.Cookie("myCookie")
    Randy Rahbar, Nov 10, 2003
    #11
  12. Larry R. Baker

    Randy Rahbar Guest

    > Now to read the cookie using server-side vbscript:
    > myVariable = Response.Cookie("myCookie")


    Eep, I screwed up all together there (I'll blame it on the lack of coffee
    this morning). Try this instead:

    To write the cookie using vbscript:
    Response.Cookies("myCookie") = "This cookie is REALLY good!"

    Now to read the cookie using vbscript:
    myVariable = Request.Cookies("myCookie")
    Randy Rahbar, Nov 10, 2003
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Layman
    Replies:
    4
    Views:
    508
    Eric Layman
    Mar 28, 2007
  2. JoeP

    What codes grab the IP address?

    JoeP, Oct 8, 2007, in forum: ASP .Net
    Replies:
    7
    Views:
    352
    Mark Rae [MVP]
    Oct 9, 2007
  3. Replies:
    3
    Views:
    434
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
    Oct 18, 2007
  4. Maziar Aflatoun

    How do I grab the client IP address in my Web service

    Maziar Aflatoun, Aug 9, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    103
  5. Joey

    grab ID# from address bar

    Joey, May 25, 2007, in forum: ASP General
    Replies:
    2
    Views:
    267
    Evertjan.
    May 25, 2007
Loading...

Share This Page