Skip to main content

Posts

Showing posts with the label javascript

Know in JavaScript if user is in Experience Editor mode in Sitecore

Sometimes we  simply want to know in JS if the user is on regular site view or experience editor view or any other view. In JS, we can do this by below lines of code -  var isEditMode = function ( ) { return typeof Sitecore !== "undefined" && Sitecore && Sitecore.PageModes && Sitecore.PageModes.PageEditor; } var isPreviewMode = function ( ) { return typeof Sitecore !== "undefined" && !isEditMode() } var isNormalMode = function ( ) { return typeof Sitecore === "undefined" }