DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Request Header Parsing in Javascript (http://www.daniweb.com/forums/thread21174.html)

nivedita Mar 30th, 2005 5:16 pm
Request Header Parsing in Javascript
 
How can we parse the request header in Java scipt to find out the protocol of the request, whether it is http or https?

Thanks in advance
Nivedita

tgreer Mar 30th, 2005 9:24 pm
Re: Request Header Parsing in Javascript
 
To my knowledge, you can't use JavaScript for this. JavaScript has a limited set of core operators, statements, and objects.

In this case, I would think the Document object would be the relevant one. I don't see any method or property of the browser DOM that returns header information (besides the "mimeType" property).

If I'm wrong, someone please correct me. I think you'll need a server-side language for this.

Comatose Mar 31st, 2005 10:42 am
Re: Request Header Parsing in Javascript
 
Just A Thought Here, Couldn't You Get The Referer With Javascript (like document.referer), and doesn't it return an entire URL? If this is so, couldn't you split the string (or use substr) and grap the protocol, and check for http: or https: and act accordingly?

tgreer Mar 31st, 2005 11:01 am
Re: Request Header Parsing in Javascript
 
That's what I get for reading posts too quickly. For some reason I had in mind the OP was asking if JavaScript could tell if the page was sent in response to a POST or GET header.

If you simply want to check the URL, then yes, your technique should work.


All times are GMT -4. The time now is 3:17 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC