SP.ClientContext.serverVersion property (sp.js)
Gets the version of the current instance of SharePoint 2013.
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var value = SP.ClientContext.get_serverVersion()
Return value
Type: String
The version of the current instance of SharePoint 2013.
Remarks
This property is available after the first time the executeQueryAsync function is executed.
Example
var clientContext;
// Make sure the SharePoint script file 'sp.js' is loaded before your
// code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
// Create an instance of the current context.
function sharePointReady() {
clientContext = SP.ClientContext.get_current();
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
var serverVersion = clientContext.get_serverVersion();
alert('Server version: ' + serverVersion);
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}