Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Print preview with specific content

  1. #1
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Print preview with specific content

    Hi,

    I was looking for a script that can make a print preview, but I need it to print only specific stuff. Mainly, all i need is for it to not print the submit and print buttons.

    Thanks
    Josh

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by izzysanime View Post
    I was looking for a script that can make a print preview, but I need it to print only specific stuff. Mainly, all i need is for it to not print the submit and print buttons.
    Create a print style sheet that hides the unnecessary elements. You link to it in a similar way to normal, only adding a media attribute:

    HTML Code:
    <link rel="stylesheet" ... media="print">
    Mike

  3. #3
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    ok, but how do you define the specific areas? Do you mean use div id= whatever?

    I used this source http://javascript.internet.com/misce...o-preview.html

    which has its on print style css, which is good, It can print preview it, but then it just prints the entire page. I made divs with ID=content.

    Thanks
    josh

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by izzysanime View Post
    ok, but how do you define the specific areas? Do you mean use div id= whatever?
    That's one way. Alternatively, you could use the class attribute. Even the document hierarchy (how the elements are nested within other elements) if that's sufficient.

    Don't. Once again, javascript.internet.com is proving to be a complete waste of bandwidth.

    Without a link to your current document, and with a clear indication of what needs to be removed, I can't be too specific.
    Mike

  5. #5
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I dont suppose you have a good example of this?

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by izzysanime View Post
    I dont suppose you have a good example of this?

    Quote Originally Posted by mwinter View Post
    Without a link to your current document, and with a clear indication of what needs to be removed, I can't be too specific.
    ??? Did you not understand what Mike said replied with? please give us a link and what you want removed

  7. #7
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    O , i understood, i thought there might be an example before you guys looked at it.

    I just needed to take out the submit and print button at bottom.

    http://wareriver.com/clients/fs/invoice_form.html

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by izzysanime View Post
    I dont suppose you have a good example of this?
    Not at the moment, no. There might be a demonstration somewhere on my webspace, but I'm not going to look for it now (it's too late and I'll be going to sleep soon).

    As you've placed the controls in a div element, this container can be hidden. First, remove the link and script element that refer to print_preview.css, and delete that file from your Web server. It's junk and if it were tangible, I'd advise you to burn it. Then, change the remaining link element from

    HTML Code:
    <link rel="stylesheet" href="form_files/style.css">
    to:

    HTML Code:
    <link rel="stylesheet" href="form_files/style.css" type="text/css" media="all">
    and add below that:

    HTML Code:
    <link rel="stylesheet" href="form_files/print.css" type="text/css" media="print">
    where print.css contains:

    Code:
    #nav {
        display: none !important;
    }
    If you discover any other tweaks necessary for printing, insert them into that file.

    Hope that helps
    Mike

  9. #9
    Join Date
    Apr 2007
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    ok, thanks for helping me. Unfortunately that does nothing. Am i supposed to change

    <input type="button" name="print" value="Print" id="print" onclick="print_preview(); return false;"/>

    to something different?

    The Print button does not work now.

    Thanks, have a good night sleep ^_^
    Josh

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by izzysanime View Post
    Unfortunately that does nothing.
    Doubtful.

    Am i supposed to change

    <input type="button" name="print" value="Print" id="print" onclick="print_preview(); return false;"/>

    to something different?
    Yes, you remove it.

    The Print button does not work now.
    It's not supposed to. The browser itself will make the changes necessary. Every browser that I can remember using has a print preview function built in, and it will use the print style sheet to determine how to render the document.

    Why duplicate functionality that someone else (the browser vendor) already went through the trouble of writing?
    Mike

Bookmarks

Posting Permissions

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