Re: Re: Newsgroup status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2011-04-27 at 18:42 +0100, Geoff Lane wrote:

> On Wednesday, April 27, 2011, Jason Pruim wrote:
> 
> > It's time for the next generation to start picking up the slack and
> > helping out and asking questions :)
> 
> To be honest, I've started three or four cries for help in the last
> few days. However, on each occasion I've spotted the answer before
> actually hitting 'Send' (and just as well because all were due to
> typos!)
> 
> However, I do have one residual question. I suspect the short answer
> to this is "No", but since the list is quiet I'll ask anyway:
> 
> Q: Is it possible to check whether Javascript is available on the
> client without using client-side Javascript to create a form and hence
> pass a variable that will only be set if Javascript is available on
> the client? Is there something in $_SERVER etc. that can provide this
> info?
> 
> TIA,
> 
> -- 
> Geoff
> 
> 


Firstly, please do not hijack a thread, if you have a question, start
your own. We won't bite if you create new threads, whereas we might a
little if you hijack ;)

There are ways to detect the general capabilities of the client machine,
however they are generalisations, and may not be accurate. Try and grab
an up-to-date browscap.ini file, and use this in conjunction with the
user agent string found in the $_SERVER array. This should tell you
whether the user agent is capable of running Javascript.

Bear in mind that this has several problems:


      * A browser might be Javascript capable but may have it turned off
        or disabled by a plugin
      * The Javascript may have been filtered out by a a firewall (which
        is rare but possible)
      * A browser could be masking as another one by giving the wrong
        user agent string
      * A browser may not even give up the user agent string, or it may
        have been filtered out somewhere along the line


A better approach is to only use the Javascript to enhance the site
progressively, and not rely on it for functionality. However, if you
really must rely on Javascript and you don't care about going to hell
for it, then why not use Javascript to pull in the content via Ajax and
leave some sort of apology notice in the cases where the content can't
be displayed. It's not often though that you really can't do something
without Javascript, unless you're doing something incredibly complex
like creating the next Google Docs. Even Facebook works on mobile
devices without Javascript.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux