// печать через фрейм
// NOTE работает в спец. браузере
function iframePrint(html) {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.contentWindow.document.write(html);
iframe.contentWindow.print();
iframe.remove();
}
// печать через окно
// NOTE не работает в спец. браузере: печать прекращается, как только закрывается окно
function windowPrint(html) {
var w = window.open();
w.document.open();
w.document.write(html);
w.document.close();
w.print();
w.close();
}
// напечатать документ
var xhr = new XMLHttpRequest();
xhr.onload = function() {
iframePrint(this.responseText);
//windowPrint(this.responseText);
}
xhr.open('GET', 'https://gist.githubusercontent.com/dizel3d/d0d890d271d36400e0659f4462e7e919/raw/480f7e09ef58d32adc5a8195241c61c6d33cf5e7/exportfile_8str.html');
xhr.send();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.