Monday 30 September 2013

How to redirect a SharePoint page to another page

Here is a simple code for making a SharePoint page, redirect to another page. These kind of scenario's are useful when we want to set any layout page as homepage for our site , as OOTB feature don't allow us to set any layout page as home page.

Add a content editor webpart to the home page and give the reference of the script (placed in style library). 
Enter below code in script file.


<script language="JavaScript">
  function redirectAfterPause() {
    setTimeout(location.href="<layouts page complete url>", 1);
  }
  _spBodyOnLoadFunctionNames.push("redirectAfterPause"); 
 </script>

The same thing can also be done by directly pasting the above code in content editor webpart.