Re: JavaScript Enabled?

From: Date: Thu, 05 Aug 2004 13:16:16 +0000
Subject: Re: JavaScript Enabled?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-192852@lists.php.net to get a copy of this message
"Kim Steinhaug" <kim@steinhaug.com> wrote in message news:20040805123059.98112.qmail@pb1.pair.com... > Indeed an old thread this one, but I still would like to know if someone > have > some input on some ways of solving this dilemma. > > Surely it is easy to detect javascript when its enabled, but what to do when > it's > not enabled is a much more interesting approach. I have several systems > online > which (maby from old habits) heavily depends on javascript functionality. > Surely > I could easily remove all javascript and do all processing and validation > serverside, > but in my honest opinion I see no practical reason to ignor javascript in > any > application. The benefits of using java is far greater than the problems. > > SOLLUTION 1 - DETECTING THE CLIENT > I would think that if we set a meta refresh to the noscript.htm and an > onload javascript > to switch to script.htm we could from theese pages set some session > variables if the > user has script or not. However this redirecting of pages is kinda silly I > think, and I > would like to think that there are other ways of doing this? Let us not > forget that > search engines would just love this sollution on our frontpage... Surely we > could add > this code and refresh the same page with ?jave=false or ?java=true, but for > some > reason I dont like this sollution. Meta refresh is bad. > > ALTERNATIVE SOLLUTION - POSSIBLE? > Hoping someone has already solved this Im throwing some thoughts here. Since > I use the session variable on all my pages, I could also create a fake gif > spacer > from a php script (eg. spacer.gif.php, which eventually spits out the gif > but lets me > do some stuff meanwhile at first). This gif could be called from javascript > document write. > A 1x1 spacer, which if I call this gif would mean that javascript would > work, > and if this script is triggered I could update the session with eg. > script=true; > Which would make me know if the user has it enabled or not? I think this would be a good way. Let Javascript write an img tag that calls a PHP script which then inserts/sets a value in your session: document.write("<img src=\"setSessionVar.php\">"); So the script is only processed if JS is enabled. No need for a redirect and you should instantly have access to the session value. Regards, Torsten Roehr > > Atleast this sounds logical in my head, aslong as I dont need to alert the > user > at once if hes got enabled java or not. This approach would mean that I can > alert the user with whatever HTML code from PHP I would want after eg. > 3 pageviews, since he would surely have the triggered the dopcument.write by > then. > (Ofcourse if he has deactivated images aswell we have problems but hey... ) > > Alot of nothing here really, but maby someone have some thoughts on the > matter. > > -- > Kim Steinhaug > ------------------------------------------------------------------------- > There are 10 types of people when it comes to binary numbers: > those who understand them, and those who don't. > ------------------------------------------------------------------------- > www.steinhaug.com - www.easywebshop.no - www.easycms.no www.webkitpro.com > ------------------------------------------------------------------------- > > > "Richard Davey" <rich@launchcode.co.uk> wrote in message > news:305004935.20040329142747@launchcode.co.uk... > > Hi all, > > > > Can anyone suggest a suitable means for detecting if a client browser > > has JavaScript enabled or not? > > > > I know this isn't exactly PHP related, but I need to make sure my PHP > > script offers an alternative in a friendly way and not a JS error, but > > I just wondered if there was a foolproof method of doing this? > > > > -- > > Best regards, > > Richard Davey > > http://www.phpcommunity.org/wiki/296.html

« previous php.general (#192852) next »