You need to sign in to do that
Don't have an account?
Sourabh Tayal 14
How to check that a visualforce page is running on Salesforce1 or on web browser?
To detect/catch that a visualforce page is running on Salesforce1 or on web browser i have used this code:
<script>
if( (typeof sforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
</script>
It is working, but when i use this same code like:
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script id="clientEventHandlersJS" language="javascript">
if( (typeof sforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
</script>
it is not working. I am using these other script tags to update records using Sforce methods.
Any one can let me know how to resolve this issue?
<script>
if( (typeof sforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
</script>
It is working, but when i use this same code like:
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script id="clientEventHandlersJS" language="javascript">
if( (typeof sforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
</script>
it is not working. I am using these other script tags to update records using Sforce methods.
Any one can let me know how to resolve this issue?
Hi sourabh ,
you can detect the browser in desktop by using just the below code
if( (typeofsforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
but in salesforce1 you need to add publisher action and visualforce page.
may be the below link must be help full
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AWfoIAG
Thanks
D Naveen rahul.
I know this code, but my issue is that i am using these 3 more scripts :
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script id="clientEventHandlersJS" language="javascript">
and these are preventing that code to run. If i comment these 3 scripts then it is working but after enable these3 script it does not work.
Do you have any idea/solution of it?
try adding them to the top ??. like below
if( (typeofsforce != 'undefined') && (sforce != null) ) {
alert('your are in SF1');
}
else {
alert('your are in Salesforce/browser');
}
<script language="JavaScript1.2" src="/js/functions.js"></script>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script id="clientEventHandlersJS" language="javascript">
if still errors persist remove the script one by one and and you capture the fault script,if the fault script is one not a salesforce one,then it could be solved easily.
what errors were showing up in the error console.
Thanks
D Naveen Rahul.
This script is the fault script.
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
But i need this script also to performe/do salesforce DML and SOQL in java-script like:
sforce.connection.query();
sforce.connection.update(); etc...
Do you have any idea how can i use both script, if possible can you try it at your end and let me know any solution?
Thanks