469,916 Members | 2,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,916 developers. It's quick & easy.

Grab IP Address with JavaScript

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?
Jul 19 '05 #1
12 13077
Personally, I don't know. Try asking in a client-side group such as
..scripting.jscript.

Ray at work

"Larry R. Baker" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?

Jul 19 '05 #2
> 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.
Jul 19 '05 #3
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" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?

Jul 19 '05 #4
ljb
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
Jul 19 '05 #5
ljb wrote:
Seems not everyone has Winsock installed.


really? must have been an oversight.

;o)

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #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" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?

Jul 19 '05 #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" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?

Jul 19 '05 #8
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" <lb****@eaglestrike.net> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?


Jul 19 '05 #9
If you user has disabled scripting, you'll cut down on the client-side
processing too.

"Larry R. Baker" <lb****@eaglestrike.net> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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" <lb****@eaglestrike.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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?


Jul 19 '05 #10

"Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Jul 19 '05 #11
> 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")
Jul 19 '05 #12
> 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")
Jul 19 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dan glenn | last post: by
reply views Thread by Baby Blue | last post: by
2 posts views Thread by Yogev | last post: by
4 posts views Thread by Eric Layman | last post: by
19 posts views Thread by JRough | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.