aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/generate-web-page.ts
blob: 990f4302ff887d22966bccbc787caf61e0fb0b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * 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: string = "Banglar Bhumi") {
	const tab = window.open("about:blank", "_blank");
	if (!tab) {
		return;
	}

	tab.document.write(content);
	tab.document.close();
	tab.document.title = title;
	tab.focus();
};