By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

How to obtain Server IP Address using Javascript

P: n/a
Hi All,

Is it possible to get the Server IP Address from Javascript

ie., when the user types "http://10.0.0.10/main.htm" in the web
browser, i need to retrive the value of the IP Address(10.0.0.10) from
my client side javascript.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Vanitha" <va*****@agilis.st.com.sg> wrote in message
news:15**************************@posting.google.c om...
Hi All,

Is it possible to get the Server IP Address from Javascript

ie., when the user types "http://10.0.0.10/main.htm" in the web
browser, i need to retrive the value of the IP Address(10.0.0.10) from
my client side javascript.


Look at:
location.host
or
location.hostname
Jul 23 '05 #2

P: n/a
Are you looking for an IP that will always be in the URL? In other words, if they go to a qualified Domain name, you would not be
able to get the IP?

If this is the case, I would use Regular Expressions to return the first match of:
/[ps]:\/\/([^\/]*\.)$\/?

Not sure on the \/... you might also try:
/[ps]://([^/]*\.)$/?

This should return the following for the following strings:
http://123.123.123.123/here.htm Returns:123.123.123.123
https://mydomain.com/here.htm Returns:mydomain.com
http://this.is.my.domain.name Returns: this.is.my.domain.name

Hope this helps.


"Vanitha" <va*****@agilis.st.com.sg> wrote in message news:15**************************@posting.google.c om...
Hi All,

Is it possible to get the Server IP Address from Javascript

ie., when the user types "http://10.0.0.10/main.htm" in the web
browser, i need to retrive the value of the IP Address(10.0.0.10) from
my client side javascript.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.