# in your layout <%= stylesheet_link_tag'styles' %> <%= javascript_include_tag :defaults %> <%= yield :script %> # ... # in the view you don't want your user to navigate away from # this is nice on very important forms or a multistep process/wizard kind of deal. <% content_for :script do %> <% end %> # below is an example of a link that can navigate away from the page without the above confirm dialog # note that we set confirmation_needed to false before we do a different confirm message. <%= link_to "cancel what i'm doing", destroy_this_info_path, :onclick => "confirmation_needed = false; confirm('You are about to destroy all this info');"%> # the "don't nav elsewhere" dialog will appear on all forms that try to submit also # we have to again set confirmation_needed to false, I do this in the submit_tag helper: <% form_tag create_somestuff_path do%> <%= text_field_tag :somestuff, "somestuff" %> <%= submit_tag "save", :onclick=>"confirmation_needed = false;"%> <% end%>