This is a discussion on Detect javascript within the PHP Language forums, part of the PHP Programming Forums category; Hi all, Is it possible to detect wether a user has enable javascript is his browser or not within PHP? ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Carved in mystic runes upon the very living rock, the last words of wj of
comp.lang.php make plain: > Is it possible to detect wether a user has enable javascript is his > browser or not within PHP? 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 http://www.phorm.com/ |
|
|||
|
wj <wjzeeuwen@home.nl> wrote in message news:<coljfd$l0$1@news4.zwoll1.ov.home.nl>...
> Hi all, > > Is it possible to detect wether a user has enable javascript is his > browser or not within PHP? <?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/ |
|
|||
|
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... > Hi all, > > Is it possible to detect wether a user has enable javascript is his > browser or not within PHP? > > Thanx, > WJ berges |
|
|||
|
Michael Fesser <netizen@gmx.net> wrote in message news:<265tq01p7r4fei13re18l1o310m6gl9b43@4ax.com>. ..
> .oO(R. Rajesh Jeba Anbiah) > > ><noscript> > ><meta http-equiv="refresh" content="0,URL='foo.php?js=0'" /> > ></noscript> > > While this might work, it's no valid HTML (noscript is not allowed in > the document's head). > 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/ |