Print Selected Area Button

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Print Selected Area Button

    Heya,
    I am trying to create a button that users can click on to print a
    specific text area of the page that I preselect. Does anyone know how to do
    that? Here is the code I used to simply print the whole page, it's close to
    what I want: <script language="Javascript1.2">
    <!--
    // please keep these lines on when you copy the source
    // made by: Nicolas - [url]http://www.javascript-page.com[/url]

    var message = "Print this Page";

    function printpage() {
    window.print();
    }

    document.write("<form><input type=button "
    +"value=\""+message+"\" onClick=\"printpage()\"></form>");

    //-->
    </script>

    withhisstripes Guest

  2. Similar Questions and Discussions

    1. Does anyone know of a pluggin to read square inches of a selected area?
      We have been manually calcutating this by selecting each spot color and using the calculator for the mulitplication. The accounting dept. needs...
    2. show area on print only.
      Hi, I have an area on a page which I would only like to show when the page is printed, not when viewed on-screen, I know I could do something...
    3. Print area has no relation to paper or printer selected?
      Using Illustrator 10. Printer is a Canon W6200 wide format printer. Media is 20'x24" roll. Ok so i set my art board to be 600(h)x1000(w)mm...
    4. Print Selected Area
      The Print Selected Area checkbox is grayed out. Colour and mono. This is new after removing ScanWizard 5 and replacing it with ScanWizard 5.7.6...
    5. the selected area is empty
      hi all have a problem when i select something and try to copy it it give me the error message : couldnt complete the copy command because the...
  3. #2

    Default Re: Print Selected Area Button

    Can't work....

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "withhisstripes" <webforumsuser@macromedia.com> wrote in message
    news:ded6bi$q0m$1@forums.macromedia.com...
    > Heya,
    > I am trying to create a button that users can click on to print a
    > specific text area of the page that I preselect. Does anyone know how to
    > do
    > that? Here is the code I used to simply print the whole page, it's close
    > to
    > what I want: <script language="Javascript1.2">
    > <!--
    > // please keep these lines on when you copy the source
    > // made by: Nicolas - [url]http://www.javascript-page.com[/url]
    >
    > var message = "Print this Page";
    >
    > function printpage() {
    > window.print();
    > }
    >
    > document.write("<form><input type=button "
    > +"value=\""+message+"\" onClick=\"printpage()\"></form>");
    >
    > //-->
    > </script>
    >

    Murray *TMM* Guest

  4. #3

    Default Re: Print Selected Area Button

    You could use a print media stylesheet that hides everything apart from the
    content you want printing.

    withhisstripes wrote:
    > Heya,
    > I am trying to create a button that users can click on to
    > print a specific text area of the page that I preselect. Does anyone
    > know how to do that? Here is the code I used to simply print the
    > whole page, it's close to what I want: <script
    > language="Javascript1.2"> <!--
    > // please keep these lines on when you copy the source
    > // made by: Nicolas - [url]http://www.javascript-page.com[/url]
    >
    > var message = "Print this Page";
    >
    > function printpage() {
    > window.print();
    > }
    >
    > document.write("<form><input type=button "
    > +"value=\""+message+"\" onClick=\"printpage()\"></form>");
    >
    > //-->
    > </script>

    rob::db Guest

  5. #4

    Default Re: Print Selected Area Button

    Yeah, that's exactly what I'd like to do, can you point me to a resource that could show me how to do that?
    withhisstripes Guest

  6. #5

    Default Re: Print Selected Area Button

    Just create a new stylesheet attached to your document, with media='print'
    as a property of the link. The new stylesheet should hide every element on
    the page apart from the one your displaying, and I guess possibly move that
    element into a sensible location for printing.


    withhisstripes wrote:
    > Yeah, that's exactly what I'd like to do, can you point me to a
    > resource that could show me how to do that?

    rob::db Guest

  7. #6

    Default Re: Print Selected Area Button

    If all you want to do is grab a certain part of the page, you could also do it
    this way:

    Wrap all the content you want printed in a <div> tag and give it an 'id'
    attribute
    Then, put an onClick handler on your 'print-page' link/button and point it to
    a javascript function.

    Here's the code:

    JAVASCRIPT
    // this javascript code opens a new window and fills it with everything inside
    the selected <div> tag

    function printPage(ID) {
    var winprint = window.open("","printer","");
    var content = document.getElementById(ID).innerHTML;
    winprint.document.open();
    winprint.document.write('<html><head><title>YOUR TITLE </title><body>');
    winprint.document.write(content);
    winprint.document.write('</body></html>');
    winprint.document.close();
    winprint.focus();
    }

    AND HERE'S THE <html> CODE:
    <body>
    <div id="print_content">
    All the content you want to show up in the new window goes here
    </div>
    </body>

    <a href="#" onClick="printPage('ID');">link/button</a>
    where ID matches the id attribute of the <div> .. in this case 'print_content'

    As a sidenote, the code for the link button does not have to be placed outside
    of the <div> tag; it can be anywhere between <body> and </body>

    rilkesf Guest

  8. #7

    Default Re: Print Selected Area Button

    Fails on Mac/IE5x however.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "rilkesf" <webforumsuser@macromedia.com> wrote in message
    news:dedman$iue$1@forums.macromedia.com...
    > If all you want to do is grab a certain part of the page, you could also
    > do it
    > this way:
    >
    > Wrap all the content you want printed in a <div> tag and give it an 'id'
    > attribute
    > Then, put an onClick handler on your 'print-page' link/button and point it
    > to
    > a javascript function.
    >
    > Here's the code:
    >
    > JAVASCRIPT
    > // this javascript code opens a new window and fills it with everything
    > inside
    > the selected <div> tag
    >
    > function printPage(ID) {
    > var winprint = window.open("","printer","");
    > var content = document.getElementById(ID).innerHTML;
    > winprint.document.open();
    > winprint.document.write('<html><head><title>YOUR TITLE
    > </title><body>');
    > winprint.document.write(content);
    > winprint.document.write('</body></html>');
    > winprint.document.close();
    > winprint.focus();
    > }
    >
    > AND HERE'S THE <html> CODE:
    > <body>
    > <div id="print_content">
    > All the content you want to show up in the new window goes here
    > </div>
    > </body>
    >
    > <a href="#" onClick="printPage('ID');">link/button</a>
    > where ID matches the id attribute of the <div> .. in this case
    > 'print_content'
    >
    > As a sidenote, the code for the link button does not have to be placed
    > outside
    > of the <div> tag; it can be anywhere between <body> and </body>
    >

    Murray *TMM* Guest

  9. #8

    Default Re: Print Selected Area Button

    Works for me on Mac/IE 5.2.

    Is there a difference between 5.2 and other 5.x versions? I'm still figuring
    out all the quirks between various browsers.


    Originally posted by: Newsgroup User
    Fails on Mac/IE5x however.





    rilkesf Guest

  10. #9

    Default Re: Print Selected Area Button

    Post a link to the page, please. Mac IE5x is incapable of responding to a
    programmatic print request on an HTML page, as far as I know. I'd love to
    see it work, however....

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "rilkesf" <webforumsuser@macromedia.com> wrote in message
    news:defjob$bd4$1@forums.macromedia.com...
    > Works for me on Mac/IE 5.2.
    >
    > Is there a difference between 5.2 and other 5.x versions? I'm still
    > figuring
    > out all the quirks between various browsers.
    >
    >
    > Originally posted by: Newsgroup User
    > Fails on Mac/IE5x however.
    >
    >
    >
    >
    >

    Murray *TMM* Guest

  11. #10

    Default Re: Print Selected Area Button

    I've just been testing it locally, but I threw up a barebones example at:

    [url]http://oct.sfsu.edu/test.htm[/url]

    As I said, works fine for me in MacIE 5.2. I've checked some other sites that
    use the same method though and, as you said, they don't work. Strange indeed!
    I must be missing something.


    Post a link to the page, please. Mac IE5x is incapable of responding to a
    programmatic print request on an HTML page, as far as I know. I'd love to
    see it work, however....




    rilkesf Guest

  12. #11

    Default Re: Print Selected Area Button

    Okay, thanks for the input, I think that helps. So the ID tag points to
    the file correct? My CSS file with the JS in it is located in the main
    directory and is called 'print.css', but I still don't get it to print. Could
    you possibly look at my code and see if you can see where I am going wrong?
    [url]www.reveration.org/devotional.htm[/url]
    Oh, and I figure if anyone is smart enough to use a Mac in the first
    place, they'll know better than to use IE. :p

    withhisstripes Guest

  13. #12

    Default Re: Print Selected Area Button

    Actually, I tinkered around a bit and found a few simple typo's, so I got it.
    Thanks so much for the help. Now... neither of you know how to get the
    submission form on the website to send its message directly to my e-mail
    without having to use a third party program would you? :/

    withhisstripes Guest

  14. #13

    Default Re: Print Selected Area Button

    > without having to use a third party program would you? :/

    Can't be done, except by using the unreliable mailto: method.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "withhisstripes" <webforumsuser@macromedia.com> wrote in message
    news:degags$ecq$1@forums.macromedia.com...
    > Actually, I tinkered around a bit and found a few simple typo's, so I got
    > it.
    > Thanks so much for the help. Now... neither of you know how to get the
    > submission form on the website to send its message directly to my e-mail
    > without having to use a third party program would you? :/
    >

    Murray *TMM* Guest

  15. #14

    Default Re: Print Selected Area Button

    Fails for me in IE5.2.3 (5815.1) OS 10.3.9.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "rilkesf" <webforumsuser@macromedia.com> wrote in message
    news:defu2f$qf5$1@forums.macromedia.com...
    > I've just been testing it locally, but I threw up a barebones example at:
    >
    > [url]http://oct.sfsu.edu/test.htm[/url]
    >
    > As I said, works fine for me in MacIE 5.2. I've checked some other sites
    > that
    > use the same method though and, as you said, they don't work. Strange
    > indeed!
    > I must be missing something.
    >
    >
    > Post a link to the page, please. Mac IE5x is incapable of responding to a
    > programmatic print request on an HTML page, as far as I know. I'd love to
    > see it work, however....
    >
    >
    >
    >

    Murray *TMM* Guest

  16. #15

    Default Re: Print Selected Area Button

    There's no link to the print stylesheet in that page.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================

    "withhisstripes" <webforumsuser@macromedia.com> wrote in message
    news:deg9u1$dks$1@forums.macromedia.com...
    > Okay, thanks for the input, I think that helps. So the ID tag points
    > to
    > the file correct? My CSS file with the JS in it is located in the main
    > directory and is called 'print.css', but I still don't get it to print.
    > Could
    > you possibly look at my code and see if you can see where I am going
    > wrong?
    > [url]www.reveration.org/devotional.htm[/url]
    > Oh, and I figure if anyone is smart enough to use a Mac in the first
    > place, they'll know better than to use IE. :p
    >

    Murray *TMM* Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139