Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var iframe = document.createElement('iframe');
- iframe.onload = function() {
- var doc = iframe.contentDocument ? iframe.contentDocument : iframe.contentWindow.document;
- doc.getElementsByTagName('body')[0].innerHTML = "<p>1234</p>";
- iframe.contentWindow.focus(); // This is key, the iframe must have focus first
- iframe.contentWindow.print();
- }
- document.getElementsByTagName('body')[0].appendChild(iframe);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement