This question already has an answer here:

I want to know if there is a way to detect if my Visualforce page which implements a custom publisher action, is running inside Salesforce1 or inside a desktop browser.

I need this since when I run my visualforce on Salesforce1 it is framed automatically by a "Cancel" and "Submit" button, however when running on the desktop I get none of these buttons so I need to add a specific button to actually save the data.

marked as duplicate by KoenVM, Samuel De Rycke, Sergej Utko, Bartley, Simon Lawrence Mar 7 '14 at 11:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 1 down vote accepted

Try that :

 if( (typeof != 'undefined') && ( != null) ) 
   alert("This is Salesforce1");    
   alert("This is Salesforce Desktop");
  • Spot on @brovasi thanks!!!, I changed the if to just "if( (typeof sforce != 'undefined') && ( != null) )" since I was getting an undefined error on sforce object – jucas Mar 5 '14 at 14:18
  • Oh yeah I wasn't sure if it was "sforce" or "", cheers man – Cloud Ninja Mar 5 '14 at 21:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.