Degrading gracefully - how to tell if JS is enabled?

Is there a RoR best practice wrt determing in a visitor’s browser has JS
disabled? Is there even a way to find out? I’ve got a couple of pages
in my app that are not going to degrade gracefully at all. I really
need to point a visitor who has JS disabled down a seperate path. Any
ideas?

Thanks,
Bill

On 7/5/06, Bill W. [email protected] wrote:

Is there a RoR best practice wrt determing in a visitor’s browser has JS
disabled? Is there even a way to find out? I’ve got a couple of pages in
my app that are not going to degrade gracefully at all. I really need to
point a visitor who has JS disabled down a seperate path. Any ideas?

This works with Firefox. No idea how IE handles it.

Put this somewhere inside your HEAD element. Change the URL to
something meaningful.

– James

On 7/5/06, Bill W. [email protected] wrote:

Is there a RoR best practice wrt determing in a visitor’s browser has JS
disabled? Is there even a way to find out? I’ve got a couple of pages in
my app that are not going to degrade gracefully at all. I really need to
point a visitor who has JS disabled down a seperate path. Any ideas?

It depends what you want to do.

You could have a split at the very beginning of your site. I haven’t
tested this

enter site

You could use this at any particular link within your site as well.
Maintaining two sets of views wouldn’t be DRY.

Or for just a few places that need special attention you can use the
tags. For a simple drop-down box form you can have a button
appear for people without Javascript.

options in here
  • Peter

On Wed Jul 05, 2006 at 01:54:32PM -0500, James L. wrote:

the raelian way to gracefully degrade is something like

respond.to do |type|
type.js {render rjs}
type.html {redict to blahblah, where rhtml is rendered}
end

not the xact syntax…

On 7/5/06, Bill W. [email protected] wrote:

Is there a RoR best practice wrt determing in a visitor’s browser has JS
disabled? Is there even a way to find out? I’ve got a couple of pages in
my app that are not going to degrade gracefully at all. I really need to
point a visitor who has JS disabled down a seperate path. Any ideas?

Hi Bill,

I just made a controller that degrades gracefully using respond_to
with html and rjs templates. I’m not sure who really has JavaScript
disabled in their browser but I was very pleased with how little extra
work it took to accommodate both. Maybe an extra 20 lines of code. For
something like a store front, where every sale is critical, this might
be a good approach.

Peter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs