Hi, I''d like to know what''s the best way to find out in RoR if the user''s browser has javascript turned off. I know some of you may yell at me for not degrading but my application must have JS on and I''d like to redirect and display a "sorry" message if JS is off. I saw some posts regarding using <noscript> tag. is that the way to go? thanks! Alan. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Alan, Alan wrote:> > I''d like to know what''s the best way to > find out in RoR if the user''s browser has > javascript turned off.I''ve got a situation I''m handling exactly the same way. In the controller: def check_js respond_to do |wants| wants.html {redirect_to :action => ''sorry''} wants.js { render :update do |page| page.redirect_to :controller => ''actor'', :action => ''edit_patient'' end } end end It''s important that the responses be in line with the request. So the html branch needs to respond with html, and the js branch needs to respond with js. You can use an RJS view, or do the render in the controller like above. But you can''t render html in the wants.js response or the respond_to won''t work. hth, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bill Walton wrote:> Hi Alan, > > Alan wrote: >> >> I''d like to know what''s the best way to >> find out in RoR if the user''s browser has >> javascript turned off. > > I''ve got a situation I''m handling exactly the same way. In the > controller: > > def check_js > respond_to do |wants| > wants.html {redirect_to :action => ''sorry''} > wants.js { > render :update do |page| > page.redirect_to :controller => ''actor'', :action => > ''edit_patient'' > end > } > end > end > > It''s important that the responses be in line with the request. So the > html > branch needs to respond with html, and the js branch needs to respond > with > js. You can use an RJS view, or do the render in the controller like > above. > But you can''t render html in the wants.js response or the respond_to > won''t > work. > > hth, > Billthanks Bill! That''s a nice solution, I haven''t even known about the existance of "respond_to" before your answer. I''m going to read some more about it but what I''m looking for is a method which could be used as a ''before filter'' in application.rb so that the "sorry, must have javascript" page will be redirected to upon entry from any page of my site if JS is disabled. I''m wondering if this method above will work for this scenario... Alan -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---