Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Aug 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Printing a hidden page.

    I want to refine the way my users can print reports on one of my web sites. Basically, I have a "print friendly page" button that will create another page with the data - absent side and top nav stuff.

    I am wondering if I can just have a print button and then create a hidden page that will call the javascript print method. I have tried creating a hidden page to no avail.

    So, my questions are: is it possible to create a hidden page and then print it? And if so, what is the syntax for creating the hidden page.

    Finally, is there a way to put the printer into landscape mode also?

    Thanks for any suggestions.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why have a print version of the page at all? Using separate CSS stylesheets for printing the page vs displaying it on the screen you should be able to hide all the elements that are inappropriate for a printed web page and even show elements that might be appropriate for the printed page but not the screen version.
    Read about media types in CSS: http://www.w3.org/TR/CSS2/media.html

    Setting page orientation should be done with CSS as well, too bad the browsers haven't bothered to implement even that basic a feature yet.
    Part of the paged media specs: http://www.w3.org/TR/CSS2/page.html#page-box
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Aug 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Roy,

    Thanks for taking the time to share this with me. I read the links you provided and while on one hand I can grasp this is the direction to go in, on the other I can't get a clear picture how to implement it.

    Is there a simple example somewhere that shows a page using media directives with the print and screen attributes?

    Thanks.

    Mike

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try: http://www.alistapart.com/articles/goingtoprint/ for a cross-browser approach. Even if you have an "all IE" audience right now, it pays to learn the standard way.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #6
    New Coder
    Join Date
    Sep 2003
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I understand you correctly you want to print the page without all the flashy stuff (pics and the like) but you don't want to switch to the page without all the pics and stuff.

    I don't see why you couldn't use frames. Make one frame has rows and cols equal to 100% that will load the main page and then make another frame that has rows and cols equal to 0% that contains the not-so-flashy version. When you hit the print button inside the main page have it print the page inside the hidden frame.
    ~SiNa94~
    http://seducius.port5.com/
    "Stab...die!"

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or similarily using a hidden iFrame:
    Code:
    <iframe style="visibility:hidden;" src="http://www.google.com" id="iFrame_hidden"></iframe>
    Sadiq.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    I'm for what Roy suggested: CSS Print. Javascript is disabled more often than CSS. You can also define an alternate document to be printed.

    <head>
    <link rel="alternate" media="print" href="printversion.doc" />
    </head>

  • #9
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    Javascript is disabled more often than CSS.
    if you were (maybe still are) developing for NN4.x, then if JS was unavailable CSS would be to, since NN rendered styles via its JS engine.

    of course, if NN4 doesn't apply to you, then this post doesn't apply either. but it's still something worth bearing mind for those that do.

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jbot
    if you were (maybe still are) developing for NN4.x, then if JS was unavailable CSS would be to, since NN rendered styles via its JS engine.

    of course, if NN4 doesn't apply to you, then this post doesn't apply either. but it's still something worth bearing mind for those that do.
    There is a population of users who surf with javascript disabled (not missing, just disabled) because most of the exploits used to remotely hack your machine while you browse a website are dependant on javascript being available.

    I know of these other solutions that were offered but I prefer the one I suggested because it's the option that leaves a developer with only one web page to update each time the page has to be changed. That translates to less work and less opportunity to forget to change the "printed" page.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #11
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Roy Sinclair
    There is a population of users who surf with javascript disabled (not missing, just disabled) because most of the exploits used to remotely hack your machine while you browse a website are dependant on javascript being available.
    yep, that includes me, too. can't be too careful these days, even when using a non-IE browser.

    Quote Originally Posted by Roy Sinclair
    I know of these other solutions that were offered but I prefer the one I suggested because it's the option that leaves a developer with only one web page to update each time the page has to be changed. That translates to less work and less opportunity to forget to change the "printed" page.
    CSS is the best method, since it's so easy to change the way the printout looks without having to code - a proper separation of style and content. sweet!

  • #12
    Regular Coder
    Join Date
    May 2004
    Location
    San Jose, CA
    Posts
    388
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd be more than happy to show how to create a CSS that doesn't display the flashy stuff on print. I used it on a site that has a map in the middle of the page. I assumed that, when people print the page, it's the map they want, not the navigational items. Making use of "display: none;" is handy in such style sheets. Here's my example:

    http://scweb.esuhsd.org/academics/map.html

    Take a look at noimage_style.css and map_print.css. It's much easier than it sounds and it's a better idea than any JS solution.
    -ts
    -Challenge The Status Quo
    -www.toddseal.com/rodin

  • #13
    New Coder
    Join Date
    Aug 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    TS,

    This is just what I am looking to do. I have been following the discussion here regarding the use of a hidden IFrame, and the use of style sheets. I went to your page and can see that this is exactly what I want to do.

    However, it was not clear to me what was going on. I could see the references to the style sheet, but when I went to print preview, how did the browser know what to send to the preview?

    Would it be possible to get some more info from you on how you did this?

    Thanks!

    Mike

  • #14
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Frames have other disadvantages. Its best to avoid them as far as possible.
    Deco
    http://www.submitboy.com
    http://www.hidden-smileys.com

  • #15
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Most of my friends are using a desktop snapshot program for printing web pages. Simple and efficient. The snapshot technology should work better with all kind of browsers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •