Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have sales report I want to print with a logo, but I don't want it shown on the screen.

I'm currently trying to use JavaScript to print a particular DIV from a page:

<script type="text/javascript">     
  function PrintDiv() {    
    var divToPrint = document.getElementById('divToPrint');
    var popupWin = window.open('', '_blank', 'width=300,height=300');
    popupWin.document.open();
    popupWin.document.write('<html><body onload="window.print()">' + 
      divToPrint.innerHTML + '</html>');
    popupWin.document.close();
  }
</script>
<a href="#" onclick="PrintDiv();">Print page</a>

Is this the right method I should use so that the logo is shown only in the printed sales report?

share|improve this question

closed as off-topic by dan, Zistoloen, Stephen Ostermiller Sep 17 '13 at 9:59

  • This question does not appear to be about webmastering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Questions about implementation are best asked at stackoverflow.com and are off-topic here. –  Stephen Ostermiller Sep 17 '13 at 10:00

1 Answer 1

Use a print stylesheet to show the logo.

Leave the logo in your on-screen version of the report, just hide that div with your normal stylesheet.

In your print stylesheet, simply display the div with the logo.

Here's a short, snappy guide to using a print stylesheet: http://www.webcredible.co.uk/user-friendly-resources/css/print-stylesheet.shtml

share|improve this answer
    
Did you mean to include a link there...? –  Andrew Lott Sep 17 '13 at 8:50
    
Sure did - sorry! added now! –  Asif N Sep 18 '13 at 9:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.