Skip to content

Commit ea88aec

Browse files
committed
Ensure page has rendered before printing
In certain situations Chrome willl fire window.onLoad before it's done rendering. Add a 100ms delay to work around this.
1 parent 7dfa1b8 commit ea88aec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/theme/index.hbs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,16 @@
241241
{{#if is_print}}
242242
{{#if mathjax_support}}
243243
<script type="text/javascript">
244-
MathJax.Hub.Register.StartupHook("End", function() {
245-
window.print();
244+
window.addEventListener('load', function() {
245+
MathJax.Hub.Register.StartupHook('End', function() {
246+
window.setTimeout(window.print, 100);
247+
});
246248
});
247249
</script>
248250
{{else}}
249251
<script type="text/javascript">
250-
document.addEventListener('DOMContentLoaded', function() {
251-
window.print();
252+
window.addEventListener('load', function() {
253+
window.setTimeout(window.print, 100);
252254
});
253255
</script>
254256
{{/if}}

0 commit comments

Comments
 (0)