if Secure statement for https and http

Discussion in 'Javascript' started by vandenberc, Mar 27, 2006.

  1. vandenberc

    vandenberc Guest

    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.
    vandenberc, Mar 27, 2006
    #1
    1. Advertising

  2. vandenberc

    Evertjan. Guest

    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)
    Evertjan., Mar 27, 2006
    #2
    1. Advertising

  3. vandenberc

    vandenberc Guest

    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/"
    vandenberc, Mar 27, 2006
    #3
  4. vandenberc

    vandenberc Guest

    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....
    vandenberc, Mar 27, 2006
    #4
  5. vandenberc

    Evertjan. Guest

    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)
    Evertjan., Mar 27, 2006
    #5
  6. vandenberc

    Evertjan. Guest

    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)
    Evertjan., Mar 27, 2006
    #6
  7. vandenberc

    vandenberc Guest

    Thank you for the tips.
    vandenberc, Mar 28, 2006
    #7
  8. vandenberc

    Evertjan. Guest

    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)
    Evertjan., Mar 28, 2006
    #8
  9. vandenberc

    Simon Guest

    "vandenberc" <> wrote in message
    news:...
    > 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.
    Simon, Mar 29, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.M
    Replies:
    5
    Views:
    5,425
    Teemu Keiski
    Jun 8, 2004
  2. zdrakec
    Replies:
    1
    Views:
    431
    zdrakec
    Jul 25, 2005
  3. Joe
    Replies:
    5
    Views:
    950
    Steven Cheng[MSFT]
    Dec 13, 2005
  4. verbal kint
    Replies:
    1
    Views:
    541
    Sudsy
    Sep 4, 2004
  5. Raven
    Replies:
    0
    Views:
    132
    Raven
    Nov 7, 2008
Loading...

Share This Page