Jump to content

[SOLVED] JS not enabled


williamZanelli

Recommended Posts

Hi guys,

 

I've coded a website, which has alot of JS, as in when someone hovers over the image it expands in size, a caption etc appears.

 

I've realised that 3% of people from my analytics data) who come to my website, dont have JS enabled, what I want is to redirect these guys to a non-JS website,

 

Any ideas on how I go about this? Can someone please post some examples..?

 

Regards

 

Will

Link to comment
Share on other sites

Just set the cookie with javascript with setcookie(); and then check if it exists like this:

 

<?
if (isset($_COOKIE['javascript'])) {
    //JS is enabled
} else {
   //JS is not enabled.. redirect.
}
?>

 

I'm gonna assume you know how to set a cookie with JS since you *did* code the website using JS. Otherwise you can just look it up or something.

Link to comment
Share on other sites

Thanks for the reply guys,

 

But i;m still not 100% with your logic,

 

So say a new user (never accessed my website in his life) types in my URL, if the JS is enabled it sets the cookie, I then check in PHP if its enabled, if it is.. ok, otherwise redirect.

 

My point of question lies in that, does the JS get called before the PHP? I was always under the impression the PHP is called first, which would mean, when the check is carried out for a new user, the Cookie is never enabled?

 

Am I right?

 

Thanks in advance for your thoughts...

Link to comment
Share on other sites

You're correct. I'd say in your situation best thing you could would be something like:

 

<noscript><meta http-equiv="refresh" content="0; url=non_js_page.php"><a href="non_js_page.php">Non-JS page...</a></noscript>

 

A

Link to comment
Share on other sites

My point of question lies in that, does the JS get called before the PHP? I was always under the impression the PHP is called first, which would mean, when the check is carried out for a new user, the Cookie is never enabled?

 

On the first request set a session variable. Then check for the cookie.

 

You're correct. I'd say in your situation best thing you could would be something like:

 

<noscript><meta http-equiv="refresh" content="0; url=non_js_page.php"><a href="non_js_page.php">Non-JS page...</a></noscript>

 

A

 

That wouldn't be valid html. The meta tag is not allowed within the body and the noscript tag is not allowed within the head.

 

 

Link to comment
Share on other sites

Personally I would just use a noscript tag with a link to the non js version.  If they have javascript disabled (not a search engine or some other type of bot) they most likely already understand that a lot of functionality from a lot of sites is going to be missing. What if they disable CSS? Do we have to support that as well?

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.