13 Gru 2008

Drukowanie fragmentu strony

function print_frag(id) {
  var div;

  div = document.getElementById(id);
  okno = window.open("", "", "toolbar=0, location=0, resizable=1, directories=0, status=1, menubar=1, scrollbars=1, height=800, width=700, top=80, left=350");
  var html = div.innerHTML;

  html = '<html><head><link rel="stylesheet" href="<a href="http://kody.wig.pl/style.css" class="mce_ws_kod">http://kody.wig.pl/style.css</a>" type="text/css" /></head><body>' + html + '</body></html>';

  okno.document.write(html);
  //okno.print();
  okno.focus();
}
<a href="javascript:print_content('fragment')">Drukuj</a>