Skip to content

Instantly share code, notes, and snippets.

@joshmcrty
Created December 11, 2013 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmcrty/7920002 to your computer and use it in GitHub Desktop.
Save joshmcrty/7920002 to your computer and use it in GitHub Desktop.
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