Newer Version Available

This content describes an older version of this product. View Latest

force:navigateToURL

Navigates to the specified URL.

Relative and absolute URLs are supported. Relative URLs are relative to the Salesforce1 mobile browser app domain, and retain navigation history. External URLs open in a separate browser window.

Use relative URLs to navigate to different screens within your app. Use external URLs to allow the user to access a different site or app, where they can take actions that don’t need to be preserved in your app. To return to your app, the separate window that’s opened by an external URL must be closed when the user is finished with the other app. The new window has a separate history from your app, and this history is discarded when the window is closed. This also means that the user can’t click a Back button to go back to your app; the user must close the new window.

mailto:, tel:, geo:, and other URL schemes are supported for launching external apps and attempt to “do the right thing.” However, support varies by mobile platform and device. mailto: and tel: are reliable, but we recommend that you test any other URLs on a range of expected devices.

Only standard URL schemes are supported by navigateToURL. To access custom schemes, use window.location instead.

Note

When using mailto: and tel: URL schemes, you can also consider using ui:outputEmail and ui:outputURL components.

This example navigates a user to the opportunity page, /006/o, using a relative URL.

1gotoURL : function (component, event, helper) {
2    var urlEvent = $A.get("e.force:navigateToURL");
3    urlEvent.setParams({
4      "url": "/006/o"
5    });
6    urlEvent.fire();
7}
This example opens an external website when the link is clicked.
1navigate : function(component, event, helper) {
2
3    //Find the text value of the component with aura:id set to "address"
4    var address = component.find("address").get("v.value");
5
6    var urlEvent = $A.get("e.force:navigateToURL");
7    urlEvent.setParams({
8      "url": 'https://www.google.com/maps/place/' + address
9    });
10    urlEvent.fire();
11}

This event is handled by the one.app container. It’s supported in Lightning Experience and Salesforce1 only. If used outside of Lightning Experience or Salesforce1, this event won’t be handled automatically. To use this event outside of one.app, create and wire up an event handler of your own.

Note

Attribute Name Type Description
isredirect Boolean Indicates that the new URL should replace the current one in the navigation history. Defaults to false.
url String Required. The URL of the target.