How to Programmatically Detect SharePoint Version from External Site: HTML/CSS/JS Clues & Techniques


1 views

When working with SharePoint integrations or migrations, identifying the version becomes crucial. Without admin access, we need to rely on frontend artifacts and behavioral patterns.

Examine these elements in the HTML source (Ctrl+U in browsers):


<!-- SharePoint 2013/2016 signature -->
<meta name="GENERATOR" content="Microsoft SharePoint">
<meta name="progid" content="SharePoint.WebPartPage.Document">

<!-- SharePoint Online (Modern) indicators -->
<script type="text/javascript" src="/_layouts/15/init.js"></script>

Create a browser bookmarklet to analyze version-specific files:


javascript:(function(){
  var spVersions = {
    '2010': '/_layouts/1033/init.js',
    '2013': '/_layouts/15/init.js',
    '2016': '/_layouts/15/16/init.js',
    'Online': 'https://static.sharepointonline.com'
  };
  
  Object.keys(spVersions).forEach(function(version) {
    var xhr = new XMLHttpRequest();
    xhr.open('HEAD', spVersions[version], true);
    xhr.onreadystatechange = function() {
      if(xhr.readyState === 4) {
        if(xhr.status === 200) {
          console.log('Potential SharePoint ' + version + ' detected');
        }
      }
    };
    xhr.send();
  });
})();

Version-specific CSS files reveal patterns:


<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/corev15.css">
<!-- 1033 = SharePoint 2010 -->
<!-- 15 = SharePoint 2013/2016 -->
<!-- 16 = SharePoint 2016 specific -->

Modern SharePoint exposes version info through REST API:


fetch('/_api/contextinfo')
  .then(response => response.json())
  .then(data => {
    console.log('SP Version:', 
      data.d.GetContextWebInformation.LibraryVersion);
  });

For regular audits, consider this Chrome extension snippet:


chrome.webRequest.onCompleted.addListener(
  function(details) {
    if(details.url.includes('/_layouts/')) {
      var versionPath = details.url.split('/_layouts/')[1];
      var versionNum = versionPath.split('/')[0];
      chrome.storage.local.get(['spVersions'], function(result) {
        var versions = result.spVersions || {};
        versions[details.tabId] = versionNum;
        chrome.storage.local.set({spVersions: versions});
      });
    }
  },
  {urls: [""]}
);

Be aware that custom solutions might:

  • Trigger security alerts on monitored systems
  • Fail on heavily customized SharePoint instances
  • Return false positives on reverse-proxied implementations

When working with SharePoint integrations or migrations, determining the underlying version is crucial for compatibility. Here are several technical approaches to identify SharePoint versions without admin access:

Examine the response headers from the SharePoint site. The MicrosoftSharePointTeamServices header often reveals version information:


// Example using PowerShell
$response = Invoke-WebRequest -Uri "https://sharepoint-site.com" -Method HEAD
$response.Headers["MicrosoftSharePointTeamServices"]

// Typical output examples:
// SharePoint 2013: "15.0.0.4420"
// SharePoint 2016: "16.0.0.4327" 
// SharePoint 2019: "16.0.0.10337"
// SharePoint Online: Doesn't expose version

Different SharePoint versions have distinct markup patterns:


// Classic SharePoint 2013/2016
<meta name="GENERATOR" content="Microsoft SharePoint">
<meta name="MicrosoftTheme" content="RTM">

// Modern SharePoint (Online/2019)
<script type="text/javascript">
    var _spPageContextInfo = {
        webServerRelativeUrl: "/sites/contoso",
        webAbsoluteUrl: "https://contoso.sharepoint.com/sites/contoso",
        webLanguage: 1033,
        currentLanguage: 1033,
        webUIVersion: 16
    };
</script>

Query the _api endpoint for version-specific behaviors:


// JavaScript example
fetch('https://site.sharepoint.com/_api/contextinfo', {
    method: 'POST',
    headers: {
        'Accept': 'application/json;odata=verbose'
    }
})
.then(response => {
    const spVersion = response.headers.get('x-sharepointhealthscore');
    console.log('Version indicator:', spVersion);
});

Check for version-unique resources:


// SharePoint 2013
/_layouts/15/start.aspx

// SharePoint 2016/2019
/_layouts/16/init.js

// SharePoint Online
/_layouts/15/sp.ui.controls.js

Here's a complete Node.js script for version detection:


const axios = require('axios');
const cheerio = require('cheerio');

async function detectSharePointVersion(url) {
    try {
        const response = await axios.head(url);
        const headers = response.headers;
        
        // Method 1: Check MicrosoftSharePointTeamServices header
        if (headers['microsoftsharepointteamservices']) {
            const version = headers['microsoftsharepointteamservices'];
            if (version.startsWith('15.')) return 'SharePoint 2013';
            if (version.startsWith('16.0.0.1')) return 'SharePoint 2019';
            if (version.startsWith('16.')) return 'SharePoint 2016';
        }

        // Method 2: Analyze HTML structure
        const htmlResponse = await axios.get(url);
        const $ = cheerio.load(htmlResponse.data);
        
        if ($('meta[name="GENERATOR"]').attr('content')?.includes('Microsoft SharePoint')) {
            return 'SharePoint 2013/2016 (Classic)';
        }
        
        if ($('script').text().includes('_spPageContextInfo')) {
            const versionMatch = $('script').text().match(/webUIVersion:\s*(\d+)/);
            if (versionMatch) {
                return versionMatch[1] === '15' ? 
                    'SharePoint Online (Legacy)' : 
                    'SharePoint Modern (2019/Online)';
            }
        }

        return 'Unknown SharePoint Version';
    } catch (error) {
        console.error('Detection failed:', error.message);
        return 'Detection Error';
    }
}

// Usage
detectSharePointVersion('https://your-sharepoint-site.com')
    .then(version => console.log('Detected:', version));

1. SharePoint Online frequently updates and may not expose version information
2. Custom solutions might alter standard patterns
3. Some methods may require authentication for accurate results
4. Always verify with multiple indicators for reliability