My css stylesheet distinguishes between media print and screen. I'd like my javascript to do the same as I have a collapsable address book. To wit: For the screen my javascript is:
Code:
<!--
 window.onload=addressbook;
 function addressbook(id) {
  var d = document.getElementById(id);
  for (var i = 1; i<=15 ; i++) {
   if (document.getElementById('saddressbook'+i)) {
    document.getElementById('saddressbook'+i).style.display='none';
   }
  }
  if (d) {d.style.display='block';}
 }
 // -->
For the print, I would want all displays. That is:
Code:
<!--
 function printaddressbook() {
  var d = document.getElementById(id);
  for (var i = 1; i<=15 ; i++) {
   if (document.getElementById('saddressbook'+i)) {
    document.getElementById('saddressbook'+i).style.display='block';
   }
  }
 }
 // -->
Is there a way that I can have the javascript detect a CTRL-P or a click on the browser's File->Print to fire this printaddressbook function, or do I have to create a "print-view" button?

Regards,

Grandpa Brian