diff --git a/docutranslate/static/index.html b/docutranslate/static/index.html index 05721ff..ad1ef00 100644 --- a/docutranslate/static/index.html +++ b/docutranslate/static/index.html @@ -2010,18 +2010,14 @@ const printTitle = match ? match[1].replace(/\.[^.]+$/, '') : ''; return r.text().then(h => ({ h, printTitle })); }).then(({ h, printTitle }) => { - if (printTitle) { - if (//i.test(h)) { - h = h.replace(/<title>[^<]*<\/title>/i, `<title>${printTitle}`); - } else { - h = h.replace(//i, `${printTitle}`); - } - } ifr.srcdoc = h; ifr.onload = () => { setTimeout(() => { ifr.contentWindow.focus(); + const originalTitle = document.title; + if (printTitle) document.title = printTitle; ifr.contentWindow.print(); + setTimeout(() => { document.title = originalTitle; }, 1000); }, 500); }; });