Advertisement
Guest User

Untitled

a guest
Jul 30th, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement