function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RumpaRumpa 

Open External URL using Lightning component

I am trying to create a lightning component which has URL (for example: www.google.com) and when clicked on the hyperlink, A new window opens up for the link. Please suggest on how can this be achieved in Lightning.
Ashif KhanAshif Khan
Hi Rumpa,

In Lightning force:navigateToURL   opens new tab for external URLs if you want to open in new tab you can use navigateToURL
 
var eUrl= $A.get("e.force:navigateToURL"); 
    eUrl.setParams({   
     "url": 'https://www.youraddress.com/'     
 });
    eUrl.fire();


in case you want to open in the same tab you need to use standard javascript as 
window.open('www.youraddress.com','_top');


I hope this will help you

Regards
Ashif
RumpaRumpa
Hi Ashif,

Thank you!
Ashif KhanAshif Khan
Hi Rumpa,

If it helps you. You can close the question so it can help others.