Newer Version Available
Navigate to a Web Page
The navigation service supports different kinds of pages in Lightning. Each page
reference type supports a different set of attributes and state properties.
Instead of using force:navigateToURL, we recommend navigating to web pages using the lightning:navigate component with the standard__webPage page type.
This code shows examples of navigating to a web page using the old force:navigateToURL event.
1// Old way to navigate to a web page
2$A.get("markup://force:navigateToURL").setParams({
3 url: 'http://salesforce.com',
4}).fire();Replace the previous code that uses force:navigateToURL with the following code. This example shows how to navigate to a web page using the standard__webPage page type. It assumes that you added <lightning:navigation aura:id="navigationService" /> in your component markup.
1cmp.find("navigationService").navigate({
2 type: "standard__webPage",
3 attributes: {
4 url: 'http://salesforce.com'
5 }
6});