Jump to content

JS and PHP


TheFilmGod

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.