Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace about:blank with hostname in footer on chrome #161

Open
Diademe opened this issue May 10, 2023 · 0 comments
Open

Replace about:blank with hostname in footer on chrome #161

Diademe opened this issue May 10, 2023 · 0 comments

Comments

@Diademe
Copy link

Diademe commented May 10, 2023

I need pages number in the printed document. One way to do it is to print with Headers and footers (an option to enable in the print dialog of Chrome and Firefox).

But this option also prints the URL (in this case, it is a popup with about:blank). I found a way to replace it with the hostname of the page from which the popup is called, but it doesn't work on Firefox (about:blank is not replaced by the hostname). This solution is not perfect, but it is better than about:blank for Chrome.

Here is a snippet that replaces about:blank with the hostname for chrome:

const popupWin = window.open(window.location.host, "", "top=0,left=0,height=auto,width=auto");
popupWin.document.open();
popupWin.document.write(`...`);
popupWin.document.close();
popupWin.history.replaceState({}, "", "/");

Would you accept a PR for this, even if it only works on Chrome ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant