blob: a93e2e29063cde4bdd77099900c41c47ea1c7e67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/**
* Opens a new browser tab and writes the given HTML content into it.
* Used to display dynamically-generated pages (e.g. PDF-printable views).
*
* @param content - The full HTML string to write.
* @param title - The document title (default: `"Banglar Bhumi"`).
*/
export function generateWebPage(content: string, title = "Banglar Bhumi"): void {
const tab = window.open("about:blank", "_blank");
if (!tab) {
return;
}
tab.addEventListener("DOMContentLoaded", () => {
tab.document.body.innerHTML = content;
tab.document.title = title;
tab.document.close();
});
tab.focus();
};
|