Scripts written for forms used in WEB applications should also apply to Dynamics 365 for phones and tablets, but there are some differences. In general, methods that are not valid for mobile applications do not return errors, but they do not return any values. Developers can use the following conditional statements to divide code that will not work in a mobile application:
Javascript
if (Xrm.Page.context.client.getClient () = "Mobile") { //ADD code that should not run in CRM for phones and tablets he Te
You can also use the Getformfactor API to set the code to run only on the phone or only on a tablet, using a statement similar to the following:
Javascript
if (Xrm.Page.context.client.getClient () = = "Mobile" && Xrm.Page.context.client.getFormFactor () = = 3) {//ADD Code that should only run in CRM for phones here}
The following list shows the effects of using a script in a mobile application. For more detailed information, see the developer documentation in the MSDN: Client programming reference.
Any other code that uses Window.alert, window.confirm, window.prompt, or prevents code from executing while waiting for a user response will not run as expected, or an error will be displayed. You should not use these methods in scripts for mobile applications.
Because the tabs that are displayed in Dynamics 365 for phones and tablets cannot be expanded or collapsed, the code that tries to expand or collapse them will not work, and the code configured for event handlers that use these events will not execute.
The WEB resource or iFrame element in the dashboard will not appear in the mobile application. The methods that interact with them do not run, and code configured for event handlers that use these methods for the events that are invoked will not run when the items are loaded. If you are interested in trying to use the preview feature for displaying Web resources or iFrame elements in Dynamics 365 for tablets, see Preview features: IFrame and Web resource support for CRM for tablets
Because Dynamics 365 for phones and tablets does not provide the ability for users to switch between different forms, the method of implementing this functionality in a WEB application will be ineffective.
Any methods used to display or navigate to related entities in the WEB application will be invalid.
Methods that will refresh the command bar, get viewport dimensions, or close the form window will not work.
Reference Address: http://www.cnblogs.com/Earson/p/dynamicsmobileformjavascript.html
Customize Dynamics 365 (four): Form scripts for phones and tablets