You are here: Re: Javascript enabled? « All PHP « IT news, forums, messages
Re: Javascript enabled?

Posted by onembk on 09/04/06 03:47

On 2006-09-03 19:36:19 -0600, cronoklee@hotmail.com said:

>>> If it is...
>>> Do the JavaScript routine.
>>> else
>>> Do the PHP equivalent Routine
>
> It wouldn't really be as simple as that MS - PHP runs on the server.
> Javascript doesn't run until it hits the user's browser ....so I guess
> you'd need to check if javascript is enabled on a previous page and
> then send that result to the next page using a form so that the server
> could process it on the way. I can't think of a better way but someone
> else probably will. Can you not just always do it in PHP? It'd be a lot
> cleaner and you don't have to worry about it being enabled or not ;c)
>
> Ciarán

I tend to avoid JavaScript when I can but one thing I've done in the
past is to have the PHP routine as the default with a JavaScript check
in a site-wide include file. You can then keep track of that
information in a cookie or a session. I keep the PHP routine as the
default in case the user enters the site on a page where form
verification (or whatever you're using JavaScript for) is necessary
before I know if I can use the JS or not.

if (!isset($_COOKIE['javascript'])) {
setcookie('javascript', javascriptTest(), $expire);
}
....
if ($_COOKIE['javascript'] == 'true') {
printJavascript();
} else {
PHProutine();
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация