Hi Darren, On Thu, 2009-06-11 at 12:23 -0700, Ruby on Rails: Talk wrote: > Hi > > Is there any way to be able to get a function (or something?!) to > print the contents of a DIV without loading the div into it's own > window etc? > > I've googled like crazy but seem to be asking the impossible. Any > ideas?
Google "CSS print stylesheet example". Hassan and Marnen are correct. The links you'll get from the search above will get you to a point where you understand what they said ;-) Basically... In the <head> section of your layout (typically application.rhtml), you specify the stylesheets you want to use and, optionally, which 'media' they're to be used for. The choices are screen, print, or all. Here's an example from one of mine. <%= stylesheet_link_tag 'application', :media => 'screen' %> <%= stylesheet_link_tag 'print', :media => 'print' %> These helper methods result in the application.css file being used to style pages sent to the screen, and the print.css file being used to style pages sent to the printer. Put the two lines above in the head section of your layout. Create an .rhtml view with the following. <body> <div id="for_screen_display"> I'm your screen buddy! </div> <div id="for_print_display"> I'm your print buddy! </div> </body> Now create the two stylesheets. application.css --------------- div#for_screen_display { display:block; } div#for_print_display { display:none; } -------------- print.css -------------- div#for_screen_display { display:none; } div#for_print_display { display:print; } When the browser loads the page, it notes that you've specified different stylesheets for different media and takes care of the rest. 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---