Bill Walton
2006-Jul-05 18:46 UTC
[Rails] 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060705/a2e5f422/attachment.html
James Ludlow
2006-Jul-05 18:54 UTC
[Rails] degrading gracefully - how to tell if JS is enabled?
On 7/5/06, Bill Walton <bill.walton@charter.net> 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. <noscript> <META http-equiv="refresh" content="1;URL=http://localhost:80/"> </noscript> -- James
Peter Michaux
2006-Jul-05 19:02 UTC
[Rails] degrading gracefully - how to tell if JS is enabled?
On 7/5/06, Bill Walton <bill.walton@charter.net> 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 <a href="http://domain.com/site_without_javascript" onclick="window.location.href=''http://domain.com/site_with_javascript; return false;">enter site</a> 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 <noscript> tags. For a simple drop-down box form you can have a button appear for people without Javascript. <form> <select onchange="this.form.submit();">options in here</select> <noscript> <input type=''submit'' value=''send this thing''/> </noscript> </form> - Peter
On Wed Jul 05, 2006 at 01:54:32PM -0500, James Ludlow wrote:> On 7/5/06, Bill Walton <bill.walton@charter.net> 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. > > <noscript> > <META http-equiv="refresh" content="1;URL=http://localhost:80/"> > </noscript>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..> > -- James > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Peter Michaux
2006-Jul-07 01:08 UTC
[Rails] degrading gracefully - how to tell if JS is enabled?
On 7/5/06, Bill Walton <bill.walton@charter.net> 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