Skip to content
Menu
SharePoint Gems
  • Power Platform
  • Development
    • SharePoint 2013
  • Migration
  • Administration
  • SP Online
  • Contact
  • About
    • Privacy Policy
SharePoint Gems

SharePoint Online: Identify Current Page is Modern page or Classic page

Posted on February 12, 2021September 29, 2021

Hello Friends,
Today we are going to explore a very interesting topic. SharePoint Online: Identify Current Page is Modern page or Classic page. We are going to learn How to identify a current page is classic page or a Modern page in sahrepoint online.

It is a very easy process in SharePoint online to identify current page is Modern page or Classic page. I will explain how to detect the current page is a modern site page or not.

The SharePoint Online itself has a special variable property called _isSPSitePage to identify the type of a page.

This (_isSPSitePage) special variable can be accessed only from the Modern SharePoint site pages. We don’t find this variable in any SharePoint classic pages like a wiki page, web part page, or other pages.

We can also access this variable from SharePoint Extensions like Application Customizer, Command Sets ..etc. This becomes very useful when we writes code based on page types.

Contents hide
1 SharePoint Online: Identify Current page is Modern Page or Classic Page
1.1 Steps:
1.2 Share this:
1.3 Like this:
1.4 Related

SharePoint Online: Identify Current page is Modern Page or Classic Page

Try this below code, which is very useful if you want to identify the page type. Follow the below steps to test this code.

Steps:

  1. Navigate to SharePoint site where you want to check the file type.
  2. Open browser web console by pressing F12 button from keyboard
  3. Copy and paste below code into your console.
var modernPage = false;
try{
    if(window._isSPSitePage)
    {
       modernPage = true;
       console.log("This is a modern site page");
    }   
    else{
    console.log("This is a Classic site page");
    }
}
catch(e){}
SharePoint Online: Identify Current Page is Modern page or Classic page

In this way, we can determine the current page is a modern site page or a Classic site page in SharePoint Online.

I hope you like this tutorial. If yes then please like and share this page. Comment below your doubts related to this topic.

You can also explore our other tutorials, hope you like it.

  • SharePoint Online: Edit Permission Level with CSOM PowerShell
  • Connect MFA enabled SharePoint site using CSOM
  • Retrieve SharePoint List Items using CSOM
  • Get Current Context from SharePoint Modern Site Page
  • How to Convert Site Page into News Post in SharePoint Online?
  • Register application in Azure portal – Part II
  • What is Required Toolchain for SharePoint Framework
  • Search In SharePoint Online

Share this:

  • Print
  • Twitter
  • Facebook
  • LinkedIn
  • WhatsApp
  • Telegram
  • Pinterest
  • Reddit

Like this:

Like Loading...

Related

2 thoughts on “SharePoint Online: Identify Current Page is Modern page or Classic page”

  1. Pingback: Solved: w3wp.exe - All Query Processing Components Are in 'Failed' Status - SG
  2. Pingback: Could not load user profile SharePoint 2013 - SharePoint Gems

Leave a ReplyCancel reply

  • Development
  • Migration
  • Poweer Apps
  • Power Automate
  • Power Platform
  • SharePoint 2013
  • SharePoint Administration
  • SharePoint Online
  • Tips
  • Uncategorized

Best of Computers

Blog Stats

  • 67,509 hits

Subscribe

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,433 other subscribers
Buy Me Coffee
©2025 SharePoint Gems | Powered by WordPress and Superb Themes!
%d