JavaScript function for secure page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    JavaScript function for secure page

    I am writing some JavaScript code and need to write one set of code if on a standard page and a different set if on a secure page.


    Does anyone know if there is a JavaScript function that tests for this?


    Thanks,

    Don

  • Mick White

    #2
    Re: JavaScript function for secure page

    John wrote:[color=blue]
    > I am writing some JavaScript code and need to write one set of code if
    > on a standard page and a different set if on a secure page.
    >
    > Does anyone know if there is a JavaScript function that tests for this?
    >
    > Thanks,
    >
    > Don
    >[/color]


    secure= (location.proto col=="https")
    if(secure){ do stuff;}
    if(!secure){ do stuff;}

    Mick

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: JavaScript function for secure page

      Mick White wrote:
      [color=blue]
      > secure= (location.proto col=="https")
      > if(secure){ do stuff;}
      > if(!secure){ do stuff;}[/color]

      Would not

      if (location.proto col.toLowerCase () == "https")
      {
      do_stuff();
      }
      else
      {
      do_other_stuff( );
      }

      be better?


      PointedEars
      --
      "This is a light sabre" - "I've never heard it called _that_ before"

      Comment

      • Mick White

        #4
        Re: JavaScript function for secure page

        Thomas 'PointedEars' Lahn wrote:
        [color=blue]
        > Mick White wrote:
        >
        >[color=green]
        >>secure= (location.proto col=="https")
        >>if(secure){ do stuff;}
        >>if(!secure) { do stuff;}[/color]
        >
        >
        > Would not
        >
        > if (location.proto col.toLowerCase () == "https")
        > {
        > do_stuff();
        > }
        > else
        > {
        > do_other_stuff( );
        > }
        >
        > be better?[/color]

        Yes and no.
        Mick

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: JavaScript function for secure page

          Mick White wrote:
          [color=blue]
          > Thomas 'PointedEars' Lahn wrote:[color=green]
          >> Mick White wrote:[color=darkred]
          >>>secure= (location.proto col=="https")
          >>>if(secure) { do stuff;}
          >>>if(!secure ){ do stuff;}[/color]
          >>
          >>
          >> Would not
          >>
          >> if (location.proto col.toLowerCase () == "https")
          >> {
          >> do_stuff();
          >> }
          >> else
          >> {
          >> do_other_stuff( );
          >> }
          >>
          >> be better?[/color]
          >
          > Yes and no.[/color]

          Care to be more specific?


          PointedEars
          --
          No one can accuse you of looking at dirty pictures when you're using Lynx.

          Comment

          Working...