1

I want to navigate two urls one after another using lightning component code,I am in Lightning Experience,I want to go Classic printable view page

My tried code:

Component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="String" />

     <div>
        <div>
            <lightning:button label="Print" onclick="{!c.navigate}" class="print-hide" />

        </div>

    </div>  
</aura:component>

Controller:

({
navigate : function(component, event, helper) {
}
})

Helper:

({
navigate : function(component, event, helper) {

     var printoption = component.get("v.recordId");

   var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url":'https://domainname/ltng/switcher?destination=classic'
    });
    urlEvent.fire();
    urlEvent.setParams({
      "url":'https://domainname'+printoption+'/p?retURL=/'+printoption
    });
    urlEvent.fire();

}
})

How to Navigate two urls at the same time one after another using lightning component code?

3
  • hm, do you want to open two new pages simultaneously ? Apr 6, 2018 at 6:40
  • @AlexanderBerehovskiy,one new page only ,first classic url redirecting that page and after that classic printable view page,not two pages, only one new page
    – user55489
    Apr 6, 2018 at 6:41
  • @AlexanderBerehovskiy ,is it possible or not?
    – user55489
    Apr 6, 2018 at 7:00

1 Answer 1

1

Yes.OfCourse. It is possible with the for loop.Here is my test code.

Cmp:

<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <lightning:button label="press" type="brand" onclick="{!c.doInit}"/> 
</aura:component>

Controller:

({
    doInit : function(component, event, helper) {
        var list = ['https://www.google.co.in/','https://www.gmail.com'];
        for(var i=0;i<list.length;i++){
            console.log(list[i])
            var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
                "url":list[i]
            });
            urlEvent.fire();
        }
    }
})

Just replace the list with your URL's. It's works Fine.

2
  • ,no it is not working
    – user55489
    Apr 9, 2018 at 6:28
  • ,if i click the button, it will open google.com page and after that navigate popup is occuring in lightining page,if we click it is openining in another new page,both the urls have to open in single page
    – user55489
    Apr 9, 2018 at 8:30

You must log in to answer this question.