How define if javascript is on with php

How define if javascript is on with php

am 16.04.2010 13:50:32 von Paulo-WORK

Hello and thanks for any replies that this message may get.
I have a issue to solve regarding PHP.
My website relies heavlly on jquery and does not dowgrade properly.
I use codeigniter framework as this website has a backend .
Is it possible to detect if js is on with php?
And if so can it be set into a variable?
Paulo Carvalho

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: How define if javascript is on with php

am 16.04.2010 13:54:44 von Ashley Sheridan

--=-5Gwh3UvunOrZuKrOtPmi
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Fri, 2010-04-16 at 12:50 +0100, Paulo-WORK wrote:

> Hello and thanks for any replies that this message may get.
> I have a issue to solve regarding PHP.
> My website relies heavlly on jquery and does not dowgrade properly.
> I use codeigniter framework as this website has a backend .
> Is it possible to detect if js is on with php?
> And if so can it be set into a variable?
> Paulo Carvalho
>


Nope, Javascript is on the client side and PHP is on the server. The
server has very little knowledge of the client, and what information is
sent (browser type, etc) can't be relied upon because browsers are
capable of lying about what they are (in order to make themselves appear
as IE for example)

JQuery should allow the site to fail gracefully into a non-Javascript
version, because of the way the framework is built.

If this is something that you cannot easily do, why don't you just have
PHP output some sort of default message that the site does not work
without Javascript and use CSS to hide the rest of the site that
requires script. Then, in JQuery, it's simple to hide the message and
show the site with a couple of lines of code.

However, I would recommend trying to get your site to fail gracefully if
it's possible, especially if it's going to be used by the public. Many
countries (including Australia, US and most of Europe) have laws
regarding accessibility now, and while the number of actual legal cases
is extremely minor, it's not a good thing to ignore. Not only that, but
even looking at the web stats offered by the W3C it shows that about 5%
have Javascript turned off. Think about the entire world population that
represents and suddenly 5% isn't such a small figure after all!

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



--=-5Gwh3UvunOrZuKrOtPmi--

Re: How define if javascript is on with php

am 16.04.2010 13:57:59 von Peter Lind

Javascript is client-side - only way to detect it is to have a page
send back information (post/get). What might work easiest is to have
jquery look for a given cookie upon page render, and if it doesn't
find it, then do an ajax call to the server. On the server side,
initiate a session for the user, set "using_javascript" to false and
update to true if you receive the ajax call.

That aside, why would you need to know in the backend if a user is
running javascript?

On 16 April 2010 13:50, Paulo-WORK wrote:
> Hello and thanks for any replies that this message may get.
> I have a issue to solve regarding PHP.
> My website relies heavlly  on jquery and does not dowgrade properly.
> I use codeigniter framework as this website has a backend .
> Is it possible to detect if js is on with php?
> And if so can it be set into a variable?
> Paulo Carvalho
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--=20

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: How define if javascript is on with php

am 16.04.2010 14:04:48 von Peter Lind

On 16 April 2010 13:54, Ashley Sheridan wrote:
> On Fri, 2010-04-16 at 12:50 +0100, Paulo-WORK wrote:
>
>> Hello and thanks for any replies that this message may get.
>> I have a issue to solve regarding PHP.
>> My website relies heavlly  on jquery and does not dowgrade properly=
..
>> I use codeigniter framework as this website has a backend .
>> Is it possible to detect if js is on with php?
>> And if so can it be set into a variable?
>> Paulo Carvalho
>>
>
>
> Nope, Javascript is on the client side and PHP is on the server. The
> server has very little knowledge of the client, and what information is
> sent (browser type, etc) can't be relied upon because browsers are
> capable of lying about what they are (in order to make themselves appear
> as IE for example)
>
> JQuery should allow the site to fail gracefully into a non-Javascript
> version, because of the way the framework is built.
>
> If this is something that you cannot easily do, why don't you just have
> PHP output some sort of default message that the site does not work
> without Javascript and use CSS to hide the rest of the site that
> requires script. Then, in JQuery, it's simple to hide the message and
> show the site with a couple of lines of code.

Or use the

Re: How define if javascript is on with php

am 16.04.2010 14:06:35 von Paulo-WORK

--------------040205090206070503000504
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 16/04/2010 12:54, Ashley Sheridan wrote:
> On Fri, 2010-04-16 at 12:50 +0100, Paulo-WORK wrote:
>> Hello and thanks for any replies that this message may get.
>> I have a issue to solve regarding PHP.
>> My website relies heavlly on jquery and does not dowgrade properly.
>> I use codeigniter framework as this website has a backend .
>> Is it possible to detect if js is on with php?
>> And if so can it be set into a variable?
>> Paulo Carvalho
>>
>>
>
> Nope, Javascript is on the client side and PHP is on the server. The
> server has very little knowledge of the client, and what information
> is sent (browser type, etc) can't be relied upon because browsers are
> capable of lying about what they are (in order to make themselves
> appear as IE for example)
>
> JQuery should allow the site to fail gracefully into a non-Javascript
> version, because of the way the framework is built.
>
> If this is something that you cannot easily do, why don't you just
> have PHP output some sort of default message that the site does not
> work without Javascript and use CSS to hide the rest of the site that
> requires script. Then, in JQuery, it's simple to hide the message and
> show the site with a couple of lines of code.
>
> However, I would recommend trying to get your site to fail gracefully
> if it's possible, especially if it's going to be used by the public.
> Many countries (including Australia, US and most of Europe) have laws
> regarding accessibility now, and while the number of actual legal
> cases is extremely minor, it's not a good thing to ignore. Not only
> that, but even looking at the web stats offered by the W3C it shows
> that about 5% have Javascript turned off. Think about the entire world
> population that represents and suddenly 5% isn't such a small figure
> after all!
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
Thanks for your replies.
I have at this stage a redirect stating that this website requires js to
work.
the website is http://paulocarvalhodesign.co.uk
I am a selfthaught wannabe developer and my goal to this private project
is to create a aplication very similar to flash.
This website does not refresh until you actually hit refresh button on
browser.
if i remove the redirect the pages will be all over the place.
please see it for yourselfs
sorry if my sppelling is not the best.
Paulo Carvalho

--------------040205090206070503000504--

Re: How define if javascript is on with php

am 16.04.2010 15:46:05 von Michiel Sikma

--0016367f9ce83790e904845ad5ff
Content-Type: text/plain; charset=UTF-8

On 16 April 2010 14:06, Paulo-WORK wrote:

> On 16/04/2010 12:54, Ashley Sheridan wrote:
>
>> On Fri, 2010-04-16 at 12:50 +0100, Paulo-WORK wrote:
>>
>>> Hello and thanks for any replies that this message may get.
>>> I have a issue to solve regarding PHP.
>>> My website relies heavlly on jquery and does not dowgrade properly.
>>> I use codeigniter framework as this website has a backend .
>>> Is it possible to detect if js is on with php?
>>> And if so can it be set into a variable?
>>> Paulo Carvalho
>>>
>>>
>>>
>>
>> Nope, Javascript is on the client side and PHP is on the server. The
>> server has very little knowledge of the client, and what information is sent
>> (browser type, etc) can't be relied upon because browsers are capable of
>> lying about what they are (in order to make themselves appear as IE for
>> example)
>>
>> JQuery should allow the site to fail gracefully into a non-Javascript
>> version, because of the way the framework is built.
>>
>> If this is something that you cannot easily do, why don't you just have
>> PHP output some sort of default message that the site does not work without
>> Javascript and use CSS to hide the rest of the site that requires script.
>> Then, in JQuery, it's simple to hide the message and show the site with a
>> couple of lines of code.
>>
>> However, I would recommend trying to get your site to fail gracefully if
>> it's possible, especially if it's going to be used by the public. Many
>> countries (including Australia, US and most of Europe) have laws regarding
>> accessibility now, and while the number of actual legal cases is extremely
>> minor, it's not a good thing to ignore. Not only that, but even looking at
>> the web stats offered by the W3C it shows that about 5% have Javascript
>> turned off. Think about the entire world population that represents and
>> suddenly 5% isn't such a small figure after all!
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>> Thanks for your replies.
> I have at this stage a redirect stating that this website requires js to
> work.
> the website is http://paulocarvalhodesign.co.uk
> I am a selfthaught wannabe developer and my goal to this private project is
> to create a aplication very similar to flash.
> This website does not refresh until you actually hit refresh button on
> browser.
> if i remove the redirect the pages will be all over the place.
> please see it for yourselfs
> sorry if my sppelling is not the best.
> Paulo Carvalho
>


The nicest way, in my opinion, is to simply display the alternative content
for the site and override it if Javascript is present. If it's turned off,
people will see your static content, and if it's on they'll get the full
experience. Having alternative content is important because it allows Google
to properly index your site.

Finding a way to check if Javascript is turned on while still in server side
is really unnecessary, since displaying alternative content and removing or
hiding it client side works just as well as redirecting to an alternative
page.

Michiel

--0016367f9ce83790e904845ad5ff--

Re: How define if javascript is on with php

am 16.04.2010 19:02:24 von TedD

At 3:46 PM +0200 4/16/10, Michiel Sikma wrote:
>On 16 April 2010 14:06, Paulo-WORK wrote:
>
>-snip-
>
>The nicest way, in my opinion, is to simply display the alternative content
>for the site and override it if Javascript is present. If it's turned off,
>people will see your static content, and if it's on they'll get the full
>experience. Having alternative content is important because it allows Google
>to properly index your site.
>
>Finding a way to check if Javascript is turned on while still in server side
>is really unnecessary, since displaying alternative content and removing or
>hiding it client side works just as well as redirecting to an alternative
>page.
>
>Michiel

Paulo:

I agree. Here's a working example with everything you need:

http://sperling.com/examples/javascript-detection/

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: How define if javascript is on with php

am 17.04.2010 11:43:03 von Michiel Sikma

--0016363ba32ce081a104846b8d9e
Content-Type: text/plain; charset=UTF-8

On 16 April 2010 19:02, tedd wrote:

> At 3:46 PM +0200 4/16/10, Michiel Sikma wrote:
>
>> On 16 April 2010 14:06, Paulo-WORK wrote:
>>
>> -snip-
>>
>
> Paulo:
>
> I agree. Here's a working example with everything you need:
>
> http://sperling.com/examples/javascript-detection/
>
> Cheers,
>
> tedd
>
>
Another important thing to consider is that the web is meant to be
accessible to even those using a screen reader. Screen readers don't support
Javascript (to my knowledge) and instead rely on properly written HTML. By
having regular content and overriding it with Javascript, you're ensuring
that the visually impaired, among others, can also use your site.

Michiel

--0016363ba32ce081a104846b8d9e--

Re: How define if javascript is on with php

am 17.04.2010 12:37:38 von Ashley Sheridan

--=-guTPzngZMUl4kRE7Jp8T
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sat, 2010-04-17 at 11:43 +0200, Michiel Sikma wrote:

> On 16 April 2010 19:02, tedd wrote:
>
> > At 3:46 PM +0200 4/16/10, Michiel Sikma wrote:
> >
> >> On 16 April 2010 14:06, Paulo-WORK wrote:
> >>
> >> -snip-
> >>
> >
> > Paulo:
> >
> > I agree. Here's a working example with everything you need:
> >
> > http://sperling.com/examples/javascript-detection/
> >
> > Cheers,
> >
> > tedd
> >
> >
> Another important thing to consider is that the web is meant to be
> accessible to even those using a screen reader. Screen readers don't support
> Javascript (to my knowledge) and instead rely on properly written HTML. By
> having regular content and overriding it with Javascript, you're ensuring
> that the visually impaired, among others, can also use your site.
>
> Michiel


Visually impaired aren't the only people that Javascript poses a problem
for. Consider someone with Arthritis or severe RSI who cannot use a
mouse as easily, if at all, as most people. A lot of Javascript uses
event handlers like onclick and onmouseover, which are specifically
geared towards using a mouse and won't work on a browser that is being
navigated by a keyboard.

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



--=-guTPzngZMUl4kRE7Jp8T--

Re: How define if javascript is on with php

am 18.04.2010 00:13:01 von TedD

At 11:43 AM +0200 4/17/10, Michiel Sikma wrote:
>By having regular content and overriding it with Javascript

It's probably best that you use the term "progressive enhancement"
rather than "overriding".

The point being is that you have a site that delivers it's content
for those with javascript turned off and those who have javascript
turned on, can enjoy an "enhanced" version of the presentation, but
not have something provided that other's can't get.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: How define if javascript is on with php

am 18.04.2010 00:17:43 von Paulo-WORK

On 17/04/2010 23:13, tedd wrote:
> At 11:43 AM +0200 4/17/10, Michiel Sikma wrote:
>> By having regular content and overriding it with Javascript
>
> It's probably best that you use the term "progressive enhancement"
> rather than "overriding".
>
> The point being is that you have a site that delivers it's content for
> those with javascript turned off and those who have javascript turned
> on, can enjoy an "enhanced" version of the presentation, but not have
> something provided that other's can't get.
>
> Cheers,
>
> tedd
I agree.
Now that i know what to do, the end result will be displaying exactlly
the same content and look regardless if JS is on or off.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: How define if javascript is on with php

am 18.04.2010 07:15:24 von Manuel Lemos

Hello,

on 04/16/2010 08:50 AM Paulo-WORK said the following:
> Hello and thanks for any replies that this message may get.
> I have a issue to solve regarding PHP.
> My website relies heavlly on jquery and does not dowgrade properly.
> I use codeigniter framework as this website has a backend .
> Is it possible to detect if js is on with php?
> And if so can it be set into a variable?
> Paulo Carvalho

This class does exactly what you are asking:

http://www.phpclasses.org/package/5297-PHP-Check-whether-Jav ascript-is-enabled-in-the-browser.html

--

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php