TheFilmGod Posted September 21, 2007 Share Posted September 21, 2007 Is their a php function to see if javascript is enabled on the visitor's computer? This would make life ten millions times. Of course, the webpages would be set up so non-javascript users don't lack presentation or usablitity, but they would miss out on some flashy presentation ( like not having to refresh the page to do something or rollover search box - you get the point. Is there something like that in php? Sry if this is posted in the wrong board. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted September 21, 2007 Share Posted September 21, 2007 google: php check if javascript enabled gave on first result http://www.thescripts.com/forum/thread541838.html I shouldn't have to do your research for you, check google/php.net befoer posting here is generally considered proper Quote Link to comment Share on other sites More sharing options...
hvle Posted September 21, 2007 Share Posted September 21, 2007 that would be NO http://www.thescripts.com/forum/thread541838.html I must be wrong! Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted September 21, 2007 Author Share Posted September 21, 2007 Thanks for the link. My question was a bit different. I realize that php can check if the "browser supports javascript, " I want to know if php can see if its enabled. Or is this not possible? I'm pretty sure its not possible, but I'm checking with you guys. Anyway, is there a way to make a javascript on the first page, do a check if JS is enabled, and if so send to php a variable $JS = false or true; I'm not sure how to do this. It wouldn't be a form, but more of script that works no matter what the user does... Thanks in advance. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted September 21, 2007 Share Posted September 21, 2007 just an option is test, if it is enabled set a session that say yes I have use js, and that will stay for teh whole trip, you need to have a config file on each page to test that would probably flash the page (i.e open it run the test then refresh it with the session value set). Quote Link to comment Share on other sites More sharing options...
hvle Posted September 21, 2007 Share Posted September 21, 2007 the function get_browser() in PHP will give you a list of what browser capable of. [javascript] => 1; Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted September 21, 2007 Author Share Posted September 21, 2007 the function get_browser() in PHP will give you a list of what browser capable of. [javascript] => 1; Well, that only gives me if javascript is supported, not if disabled or enabled. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted September 21, 2007 Share Posted September 21, 2007 well then test with javascript if javascript is enabled then set a session value via ajax if it is, otherwise the session can't be set Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted September 21, 2007 Author Share Posted September 21, 2007 Thanks cooldude, but how do I do that? I never used ajax and php together. Do you have any good links with examples? I'm on google searching, but so far I only found scripts that redirect you if JS is enabled. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 21, 2007 Share Posted September 21, 2007 The way I have heard people do this is to set a cookie using JS, then have PHP check if the cookie is set. Of course, since JS runs after PHP, you need to run the JS page, then go to a new page which has the PHP check. This is considered EVIL by google's robots and they will get mad at you. The best thing to do is make sure your site works no matter what. So you make everything work without JS, then use JS to add other spiffy stuff. What are you trying to do? http://mootools.net is a good js library with ajax. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted September 21, 2007 Share Posted September 21, 2007 that is what you need, a redirect to a page if js is enabled so that if it is that page will set the session saying it is basicalyl a script like this <?php session_start(); if(!isset($_SESSION['js_enabled'])){ //test for js } ?> The test redirect to a session making page that sets js_enabled to 0 or 1 and then based on that you can have your varying page views. it onyl needs to happen once and it will do a bit of funky reload, but wil lwork. Edit: A cookie might be a stronger advanatage here to have this happen as least as possible, also if you worried abotu google robot set in a google robot hack saying if(Ip = goolge robot) divert all js text Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.