Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drop this inside a <script> tag in a Content Editor Web Part to redirect a page to another URL without creating an entry in the browser history. Based on a blog post I wrote at http://joshmccarty.com/2011/08/redirect-in-sharepoint-using-meta-vs-javascript/ and @PathToSharePoint's easy tabs script to detect whether a page is in edit mode.
;( function() {
if ( document.forms[0].elements["_wikiPageMode.value"] == "true" || document.forms[0].elements["MSOLayout_InDesignMode"].value == "1") {
return;
}
window.location.replace('http://your-url-goes-here');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment