fix bug that causes script to crash on stylesheets without any rules (ex. css with all font-faces). added feature that automatically opens the print window when clicking on the button
This commit is contained in:
parent
91cca5dac1
commit
0a54573a7b
|
@ -22,15 +22,19 @@ function __PrintScreen__removePrintMedia() {
|
||||||
|
|
||||||
function convertStyleSheet(stylesheet) {
|
function convertStyleSheet(stylesheet) {
|
||||||
convertMedia(stylesheet.media);
|
convertMedia(stylesheet.media);
|
||||||
|
if(stylesheet.rules) {
|
||||||
for(var i=0; i<stylesheet.rules.length; i++) {
|
for(var i=0; i<stylesheet.rules.length; i++) {
|
||||||
convertMedia(stylesheet.rules[i].media);
|
convertMedia(stylesheet.rules[i].media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var stylesheets = document.styleSheets;
|
var stylesheets = document.styleSheets;
|
||||||
for(var i=0; i<stylesheets.length; i++) {
|
for(var i=0; i<stylesheets.length; i++) {
|
||||||
convertStyleSheet(stylesheets[i]);
|
convertStyleSheet(stylesheets[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it seems to print a blank page if the DOM does not have time to rebuild
|
||||||
|
setTimeout(function() { window.print(); }, 1000);
|
||||||
}
|
}
|
||||||
__PrintScreen__removePrintMedia();
|
__PrintScreen__removePrintMedia();
|
Loading…
Reference in New Issue
Block a user