Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

2 Answers 2

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 case of, you are inside the Salesforce1 Mobile App, you can use the 'sfoce' Javascript object to identify mobile vs desktop:

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

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

 
discard

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.