Link to home
Start Free TrialLog in
Avatar of jilim
jilim

asked on

How to capture HTTP headers in JavaScript?

Dear Experts,

In JavaScript, how can i accquire HTTP headers such as Remote Address, Request Method and so on?

Basically what i know in ASP is, u just need to type in as follow :-
 RemoteAddress = request.servervariables("remote_addr")

If my server is having internal IP & External IP and i would like give the different response base on the IP, how can i do it in JavaScript?

Example in ASP :
Internal IP = 123.456.789
External IP = 987.654.321

IF left(request.servervariables("remote_addr"),9) = "123.456.7" then
response.redirect "123.456.789/index.asp"
Else
response.redirect "www.mydomain.com/index.asp"
END IF

Experts, Plz share out your ideas....
Thanx

Regards,
Jilim :)

Avatar of third
third
Flag of Philippines image

AFAIK, you cannot get http headers on the client side.
Avatar of jilim
jilim

ASKER

Hi third,

Basically i'm hosting the web server. And my situation goes like this :-

from my pageOne.htm, there is a link called pageTwo.htm with the URL "../Home/pageTwo.htm". If the users from our internal network, i would like the it to display the URL as "123.456.789/Home/pageTwo.htm", if the user from external then the URL will display as "http://www.mydomain.com/Home/pageTwo.htm"

basically i juz want to detect the user is internal or external by using the the server IP address
ASKER CERTIFIED SOLUTION
Avatar of third
third
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are running DNS servers on your internal network, you could use this to resolve the domain to a different IP for your internal users.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: third {http:#8039891}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer