How to use window.open() but still focus on original window on Chrome, Angular 14?

235 Views Asked by At

I want to traverse the array and open its elements in the new Chrome Tab with their link. However, I don't want it to focus on the new Tab. Just focus on the original window.

Does anybody know any way to do it, please?

        for (let i = 0; i < this.linkSearchList.length; i++) {
            if (this.linkSearchList[i].note) {
                const newTab = window.open(this.linkSearchList[i].link, "_blank");
                if (newTab)
                    this.openingLinkSearchList.push(newTab);
            }
        }

I have tried to use newTab.blur() and window.focus() after opening new Chrome Tabs but it doesn't work

        for (let i = 0; i < this.linkSearchList.length; i++) {
            if (this.linkSearchList[i].note) {
                const newTab = window.open(this.linkSearchList[i].link, "_blank");
                if (newTab) {
                    this.openingLinkSearchList.push(newTab);
                    newTab.blur();
                }

            }
        }
        setTimeout(() => {
           window.focus();
        }, 100);
0

There are 0 best solutions below