Detect javascript

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

    Detect javascript

    Hi all,

    Is it possible to detect wether a user has enable javascript is his
    browser or not within PHP?

    Thanx,
    WJ
  • Alan Little

    #2
    Re: Detect javascript

    Carved in mystic runes upon the very living rock, the last words of wj of
    comp.lang.php make plain:
    [color=blue]
    > Is it possible to detect wether a user has enable javascript is his
    > browser or not within PHP?[/color]

    No, but it's possible to detect it with Javascript; you can then pass
    that information on to PHP. It's a two-step process, though. Your first
    page is something like this:

    <META HTTP-EQUIV=Refresh CONTENT="1; URL=jstest.php? js=no">

    <SCRIPT TYPE="text/javascript">
    location = "jstest.php?js= yes";
    </SCRIPT>

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: Detect javascript

      wj <wjzeeuwen@home .nl> wrote in message news:<coljfd$l0 $1@news4.zwoll1 .ov.home.nl>...[color=blue]
      > Hi all,
      >
      > Is it possible to detect wether a user has enable javascript is his
      > browser or not within PHP?[/color]

      <?php
      //foo.php
      $js = 1;
      if (isset($_GET['js']) && $_GET['js']=='0')
      $js = 0;
      ?>
      <noscript>
      <meta http-equiv="refresh" content="0,URL= 'foo.php?js=0'" />
      </noscript>
      <?php
      echo $js;
      //etc etc
      ?>

      --
      <?php echo 'Just another PHP saint'; ?>
      Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

      Comment

      • Michael Fesser

        #4
        Re: Detect javascript

        .oO(R. Rajesh Jeba Anbiah)
        [color=blue]
        ><noscript>
        ><meta http-equiv="refresh" content="0,URL= 'foo.php?js=0'" />
        ></noscript>[/color]

        While this might work, it's no valid HTML (noscript is not allowed in
        the document's head).

        Micha

        Comment

        • markus berges

          #5
          Re: Detect javascript

          Yo wj,

          Why not simply set a value to a hiddenfield
          using a simple javscript-function?

          If there is the expected value within
          your POST-VARS after submit ...

          "wj" <wjzeeuwen@home .nl> schrieb im Newsbeitrag
          news:coljfd$l0$ 1@news4.zwoll1. ov.home.nl...[color=blue]
          > Hi all,
          >
          > Is it possible to detect wether a user has enable javascript is his
          > browser or not within PHP?
          >
          > Thanx,
          > WJ[/color]

          berges


          Comment

          • R. Rajesh Jeba Anbiah

            #6
            Re: Detect javascript

            Michael Fesser <netizen@gmx.ne t> wrote in message news:<265tq01p7 r4fei13re18l1o3 10m6gl9b43@4ax. com>...[color=blue]
            > .oO(R. Rajesh Jeba Anbiah)
            >[color=green]
            > ><noscript>
            > ><meta http-equiv="refresh" content="0,URL= 'foo.php?js=0'" />
            > ></noscript>[/color]
            >
            > While this might work, it's no valid HTML (noscript is not allowed in
            > the document's head).
            >[/color]

            Yes, this a good criticism:-) What about this one, which doesn't
            rely on meta refresh as browsers could disable it.

            <?php
            //foo.php
            $js = (isset($_GET['js']) && $_GET['js']=='1') ? 1 : 0;
            if (!$js)
            {
            ?>
            <script>
            window.location = "foo.php?js =1";
            </script>
            <?php
            }

            echo $js;
            //etc etc
            ?>

            Also, if form is allowed to check the JS, it will be much easier
            as we can populate any variables on onSubmit event. Also, it could be
            much easier to do that in web bug.

            --
            <?php echo 'Just another PHP saint'; ?>
            Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

            Comment

            Working...