I am currently facing an issue in opening an url in a new tab on Salesforce 1 (Mobile) platform. The sforce.one.navigateTo() method does not have any option to open url in a new tab. Any suggestions as to how could i open the URL in a new tab?
3 Answers
You don't have the concept of tabs inside the Salesforce1 application - it isn't running in a browser, rather in a webview which allows an installed application to display web content.
If your URL is external to Salesforce, then using sforce.one.navigateToURL() will open the page in a child browser window - this isn't a new tab, but does "popup" a new page over the existing one, without interfering with navigation.
I have found that using window.open() JavaScript method on iOS will open the child browser window regardless of whether the URL is internal or external. However, this is not documented behaviour and doesn't do anything on Android.
The bottom line is that you have no supported control over the navigation/new window behaviour of the Salesforce mobile application - you can't bypass the sforce.one functions to interact directly with the Cordova container as the container isn't exposed to your custom pages.
As per the navigation documentation, from within Salesforce1, new window (I presume tabs as well) cannot be opened:
Don’t use target="_blank" in navigation URLs; you can’t open new windows inside Salesforce1.
There is no functionality of opening new tab or window within Salesforce1 container on native UI.
There is one option:
1) You can use sforce.one.navigateToURL
to redirect the page. Call sforce.one.back()
function by javascript when you are done with it.
You can't do multitasking through Salesforce 1 with user interaction.
Sometimes window.open
and window.showModalDialog
work but they are not officially supported and Salesforce does not recommend to use them.