iam trying to open in new tab in background with angular, already browsing about this but it seems still doesn’t works.
please see the function below :
openProductInNewTab(productId: number) {
const url = this.router.serializeUrl(this.router.createUrlTree(['/product', 'detail', productId]));
// Buka tab baru
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
setTimeout(() => {
if (newWindow) {
window.focus(); // Kembali ke tab utama
}
}, 500);
}
here i attached the html code :
<td style="width: 27%; padding-left: 20px" nowrap *ngIf="this.ls.selectedLanguages == 'id'">
<strong (click)="openProductInNewTab(item.id)" class="text-blue">
{{ item.name }}
</strong>
</td>
so the problem is, my browser (edge) is always open the new tab directly and never go back to the main tab. I want to stay focus on main tab and just open the new tab in background tab for the ideal solution. Do you have any alternative solution about this ? Thank you because iam getting stuck.
i have already trying iframe, put the url on variable a, add the windows.blur() but none of these ever work on my local instead.