Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best option to implement visualforce page with view for desktop and mobile at the same place. Can this be handled automatically with modern javascript frameworks like backbone.js, angular.js, etc. For example there is Vf page and this page automatically calculates which view template to use(mobile or desktop), which model to use(mobile and desktop). Actually the mobile and desktop content and behaviour are the same but ui will be reorganized responsively within mobile.

share|improve this question

Simple VisualForce pages render reasonably well in Salesforce1 as they are, but if this is general viewing via browser you'll probably find things aren't looking great. If I was going to do this I'd use Bootstrap - it's designed for creating responsive pages easily and wouldn't have an overhead as large as other frameworks.

share|improve this answer

In the case that you are inside the Salesforce1 Mobile App, you can use the 'sforce' Javascript object to identify mobile vs desktop:

// Do something in inside the Salesforce1 Mobile App
if( (typeof sforce != 'undefined') && (sforce != null) ) {
  // Salesforce1 navigation;
else {
  // Set the window's URL to the Visualforce page for use on Desktop
  window.location.href = '{!URLFOR($Action.Account.View, account.

*Note: This will be present if you navigate to /one/, whether that be the Salesforce1 mobile app, in your mobile browser, or a desktop/laptop browser navigated to /one/

You can also use Apex to identify the user agent

 global static Boolean isMobile() {
      String device = System.currentPageReference().getParameters().get('device');
      return (device == 'mobile');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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