hide items for print

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    hide items for print

    i am new to javascipt and i want to print a selected area of the asp page to print through javascript ...is there any solution plz guide
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    http://www.killersites .com/mvnforum/mvnforum/viewthread?thre ad=5278

    Refer this link I hope Its usefull for u

    vssp

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Easiest way to acomplish this is to make a 'print-only' style sheet. This means that you make a CSS sheet and include that in your script with e.g.
      [html]<link rel="stylesheet " media="print" type="text/css" href="noprt.css " />[/html].
      Take notice of the media="print" attribute. This stylesheet will be used by default whenever you print.
      Within the style sheet you can define, for example a class [html].nopr { display:none; }[/html].
      When you define that class in all elements that you do not want to be printed, (class="nopr") you will only print those parts of the screen that you want.

      Ronald :cool:

      Comment

      • omerbutt
        Contributor
        • Nov 2006
        • 638

        #4
        hide items for print

        sir i want to print a report that is in an html page i have made a button that calls the javascript function window.print for e.g.
        <td class="table">< input type="button" name="Print1" value="Print1" onClick="javasc ript:window.pri nt()"></td>


        now when it prints it prints the whole page including the print and logout buttons that are at the end of the page ....now how can i ommit those 2 buttons in print ...can any body help me

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Hide the buttons before the print:
          Code:
          btn.style.display='none';
          assuming 'btn' is the button object.

          Comment

          • dragshort98
            New Member
            • Apr 2007
            • 1

            #6
            i ve already do it but the button still displayed on the printout

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              You need to use print style sheets. See link.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                I've changed the title to better reflect the problem.

                Comment

                • Gyanchand
                  New Member
                  • Jul 2007
                  • 35

                  #9
                  [HTML]<!-- Paste this code into the STYLE section of your HTML document
                  so the button itself will not print -->

                  @media print {
                  input.noPrint { display: none; }
                  }


                  <!-- Paste this code into the BODY section of your HTML document -->

                  <input class="noPrint" type="button" value="Print This Page" onclick="window .print()">[/HTML]
                  Last edited by gits; Jul 20 '07, 08:23 AM. Reason: added CODE-tags

                  Comment

                  Working...