+ Start a Discussion
Emily Johnson 23Emily Johnson 23 

navigateToURL using window.open causes original page URL to change

I'm using e.force:navigateToURL for clickable links in my lightning component. I have tried several different ways of creating this url. I need it to open the links in a new tab so that the original window remains open. 

When the links are clicked, it opens the URL in a new window (as expected), but it's also changing the original window's URL. How do I prevent this from happening?

Here is my function:
handleClick : function(component, event, helper) {  
        var baseURL = component.get("v.cbaseURL");
        var viewRecordEvent = $A.get("e.force:navigateToURL");
             "url": window.open(baseURL+'/'+ event.target.id,'_blank')              
Here are some screenshots showing the behavior.

Lightning component with clickable link:
User-added image

New tab that is opened:
User-added image

Original tab (after clicking link):
User-added image
Ankita Rustagi 11Ankita Rustagi 11
Hi Emily, I am also facing the same issue. Were you able to resolve the issue. If so, please post the solution. Thanks!
Emily Johnson 23Emily Johnson 23
Hi Ankita,

For this particular item, I ended up changing the click handler to this:
//open links in edit mode
    handleClick : function(component, event, helper) {         
        var editRecordEvent = $A.get("e.force:editRecord");
         	"recordId": event.target.id

Hope it helps.