if Secure statement for https and http

V

vandenberc

I am trying to setup an html page. I have a button and when you click
on it I want it to go to either http:///.../demo.htm or
https://..../demo.htm based on whether or not you went through the
crypted site or the uncrypted site. I know that I can make a relative
address but since the link that I want is not on the same server I
can't do that. I just want a script that says

if secure
document.load "https:// this secure web address"
else
document.load "http://this non secure address"

I am new to programming and I would really appreciate any guidance.
Thanks.
 
E

Evertjan.

vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
I am trying to setup an html page. I have a button and when you click
on it I want it to go to either http:///.../demo.htm or
https://..../demo.htm based on whether or not you went through the
crypted site or the uncrypted site. I know that I can make a relative
address but since the link that I want is not on the same server I
can't do that. I just want a script that says

if secure
document.load "https:// this secure web address"
else
document.load "http://this non secure address"

if (/https:\/\//.test(location.href))
location.href = "https://blahblah.com/"
else
location.href = "http://blahblah.com/"

or shorter:

location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"
I am new to programming and I would really appreciate any guidance.

If you are so new to programming,
perhaps you should reconsider working on site security?
 
V

vandenberc

The site I am going to is secure already I just need the button to link
to either the secure link or the nonsecure link based on if they typed
in http ot https....
 
E

Evertjan.

vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
The site I am going to is secure already I just need the button to link
to either the secure link or the nonsecure link based on if they typed
in http ot https....

This is usenet, not email, so:
Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>
 
E

Evertjan.

vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
Great. So what exactly do I put where it says
((/https:\/\//.test(location.href)) and in the ? and :
Thanks so much for your help.

Use the code as is!
Read up on regular expressions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top