Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

remove "about:blank" when window.open()

I have a function that will dynamicaly window.open() to a specific resource.
I would like to remove the "about:blank" that appears while the page load and display a loading message.

Is it possible ?

Here is my function :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const windowReference = window.open();

    try {
        AppProductAuthenticationApi.getUrlAccess(apuaId, query).then((res: {urlAccess: string} | undefined | null) => {
            if (res && res.urlAccess) {
                windowReference &&
                    (windowReference.location = `${res.urlAccess}${
                        null !== queryString && typeof queryString !== "undefined" ? queryString : ""
                    }`);
            } else {
                windowReference && windowReference.close();
            }
        });
    }

>Solution :

Yes, it is possible to remove the "about:blank" page and display a loading message while the page is loading. Here is one way you could do this:

Add an event listener to the load event of the new window.

windowReference.addEventListener('load', () => { Do something when the page has finished loading });

Inside the event listener function, you can use the windowReference.document property to access the document object of the new window:

    windowReference.addEventListener('load', () => {
 windowReference.document.body.innerHTML = '';
windowReference.document.body.innerHTML = '<h1>Loading...</h1>';
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading