0

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

3
Contributors
3
Replies
5
Views
12 Years
Discussion Span
Last Post by tgreer
0

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.

0

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?

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.