SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I check if a page is in ?pagepreview=true mode?

I've branded the sharepoint ribbon and need to check if a page is in pagepreview to get the site branded correct (js / css). Is there a way to do this without checking the url with JS

window.loaction.href.indexOf("?pagepreview=true") > -1

I'm trying to check this in the ex masterpage.

share|improve this question
Are you asking if there is a different way to check it in JavaScript, or if there is a way to check it WITHOUT using JavaScript? Where are you checking for this, within a Content Editor Web Part? Within the master page? Where? – CigarDoug Jan 21 '13 at 16:34
I'm looking for a way to check this with javascript. – Plexus81 Aug 27 '13 at 10:31

On the server side you can check QueryString params

bool isPagePreviewMode = Convert.ToBoolean(HttpContext.Current.Request.QueryString["pagepreview"]);

share|improve this answer

Your Answer


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.