By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,272 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,272 IT Pros & Developers. It's quick & easy.

if Secure statement for https and http

P: n/a
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.

Mar 27 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #2

P: n/a
Great. So what exactly do I put where it says
((/https:\/\//.test(location.href)) and in the ? and :
Thanks so much for your help.
location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"

Mar 27 '06 #3

P: n/a
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....

Mar 27 '06 #4

P: n/a
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/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #5

P: n/a
vandenberc wrote on 27 mrt 2006 in comp.lang.javascript:
location.href = (/https:\/\//.test(location.href))
? "https://blahblah.com/"
: "http://blahblah.com/"
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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 27 '06 #6

P: n/a
Thank you for the tips.

Mar 28 '06 #7

P: n/a
vandenberc wrote on 28 mrt 2006 in comp.lang.javascript:
Thank you for the tips.


What tips?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 28 '06 #8

P: n/a
"vandenberc" <va********@telspan.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Thank you for the tips.


Thank you for ignoring them.

Simon
--
http://urlkick.com/
Free URL redirection service. Turns a long URL into a much shorter one.
Mar 29 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.