SHARE
TWEET

Untitled

a guest Jul 30th, 2013 25 Never
  1. var iframe = document.createElement('iframe');
  2.  
  3. iframe.onload = function() {
  4.     var doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document;
  5.     doc.getElementsByTagName('body')[0].innerHTML = "<p>1234</p>";
  6.  
  7.     iframe.contentWindow.focus(); // This is key, the iframe must have focus first
  8.     iframe.contentWindow.print();
  9. }
  10.  
  11. document.getElementsByTagName('body')[0].appendChild(iframe);
RAW Paste Data
Top