Detect javascript

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? ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-02-2004
wj
 
Posts: n/a
Default Detect javascript

Hi all,

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

Thanx,
WJ
Reply With Quote
  #2 (permalink)  
Old 12-02-2004
Alan Little
 
Posts: n/a
Default Re: Detect javascript

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/
Reply With Quote
  #3 (permalink)  
Old 12-02-2004
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: Detect javascript

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/
Reply With Quote
  #4 (permalink)  
Old 12-02-2004
Michael Fesser
 
Posts: n/a
Default Re: Detect javascript

.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).

Micha
Reply With Quote
  #5 (permalink)  
Old 12-02-2004
markus berges
 
Posts: n/a
Default 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...
> Hi all,
>
> Is it possible to detect wether a user has enable javascript is his
> browser or not within PHP?
>
> Thanx,
> WJ


berges


Reply With Quote
  #6 (permalink)  
Old 12-02-2004
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: Detect javascript

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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:13 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0