Lightning Component to Open URL in Browser New Tab on Button Click

Lightning Component:

<aura:component implements="flexipage:availableForAllPageTypes, force:appHostable" access="global">
    <aura:attribute name="recordId" type="string" default="0019000001DEV5z"/>
    <div class="slds-m-around--xx-large">
        <!--Open URL in New Browser Tab-->
        <lightning:button label="Open in New Window" variant="brand" onclick="{!c.handleOpenInNewWindow}"/>
        <!--Open URL in New Browser Tab With Record Id-->
        <lightning:button label="Open in New Window With RecordId" variant="brand" onclick="{!c.handleOpenNewWindowWithRecordId}"/>

Lightning JS Controller:

    //Open URL in New Browser Tab
    handleOpenInNewWindow : function(component, event, helper) {"", '_blank');
    //Open URL in New Browser Tab With Record Id
    handleOpenNewWindowWithRecordId : function(component, event, helper) {
        var recordId = component.get('v.recordId');'/' + recordId,'_blank');

  • manu

    This opens the link in new browser.
    Can we open within same app.. same window.. in a new lightning tab?
    Like a console app.

    • for console you have to write different code for console tab or sub tab