We have an application that pulls URLs from configuration and creates buttons for such user defined URLs. Because we are in a console navigation environment, every time these URLs are internal, instead of opening a new browser tab, it creates a console sub-tab.
Initially I thought it was great, but noticed many of the pages are not optimized to finalize under a console tab (return URLs and redirects break the tab on finish) so now I'm wanting all pages to open in a new browser tab. Currently invoking a redirect NavigationMixin.Navigate which works fine for externally hosted pages. Is there a way to change this behavior for same domain pages? The premise is that I can't touch the destination pages at all, just the page with the buttons in the console.
redirectTile(){
if(this.tileUrl){
if (this.tilePageRegion==='New Tab'){ // open new tab
this[NavigationMixin.Navigate]({
type: 'standard__webPage',
attributes: {
url: this.tileUrl
}
},
);
}else {
location.href = this.tileUrl; //Same page replaces full page
}
}
}
Best Answer
if you want new browser tab, you should not really use
NavigationMixin
- it will simply add the url to current url as it takes it as partial url (bug). So, instead you can use window.open directly: