Newer Version Available
force:navigateToURL
Relative and absolute URLs are supported. Relative URLs are relative to the Salesforce mobile web 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.
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}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}| Attribute Name | Type | Description | Required? |
|---|---|---|---|
| isredirect | Boolean | Indicates that the new URL should replace the current one in the navigation history. Defaults to false. | |
| url | String | The URL of the target. | Yes |