• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

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

0
jilim
Asked:
jilim
1 Solution
 
thirdCommented:
AFAIK, you cannot get http headers on the client side.
0
 
jilimAuthor Commented:
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
0
 
thirdCommented:
jilim,

  sorry but what you want cannot be done with javascript. you have to use ASP (or any other server-side script) to grab the remote ip address. if you don't like the use ASP on the whole site then you have to at least use request.servervariables("remote_addr") on the first page then save it to a javascript variable then you can pass it along to the rest of the pages by using cookies or set it as a querystring on each of the URL.
0
 
bjorsqCommented:
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.
0
 
jaysolomonCommented:
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
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now