1

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.

enter image description here

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
        }  
    } 
}
2

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:

if (this.tilePageRegion === 'New Tab') {
    window.open(this.tileUrl, '_blank');
}
| improve this answer | |
  • TY, worked as stated! I'm not sure why I was confusing DOM containment for "document" and "window" (only query LWC restrictions) with other operations using those two objects. I was also misled by the LWC documentation on navigation and best practices because it states to use 'lightning/navigation' developer.salesforce.com/docs/component-library/bundle/… – Glen De Marcos Sep 10 '19 at 5:26
  • In Aura or LWC you have access to window and document, but only that they are secure versions and only limited methods on them are exposed - so you can use those exposed methods on secure window/document objects – salesforce-sas Sep 10 '19 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.