?
Solved

How to capture HTTP headers in JavaScript?

Posted on 2003-02-27
6
Medium Priority
?
425 Views
Last Modified: 2012-08-13
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
Comment
Question by:jilim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 30

Expert Comment

by:third
ID: 8039016
AFAIK, you cannot get http headers on the client side.
0
 

Author Comment

by:jilim
ID: 8039132
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
 
LVL 30

Accepted Solution

by:
third earned 400 total points
ID: 8039891
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
 

Expert Comment

by:bjorsq
ID: 8042724
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
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10096205
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question