Redirect user to another page in SharePoint 2013/2016/Online using JavaScript or jQuery

sharepoint 2013 redirect page to another page

Here we will discuss various ways to redirect a user to another page in SharePoint 2013/2016 or SharePoint Online using JavaScript or jQuery. SharePoint 2013 redirect page to another page is a very common requirement where users will be redirected to another page in SharePoint 2013/2016 or SharePoint Online. The destination page can be a page exists in the SharePoint site or it can be an external page.


Below are a few options you can use to redirect page to another page in SharePoint 2013/2016 or SharePoint Online.

We can add a script to redirect a page to another page in SharePoint. In various ways, you can add a script to a SharePoint page to redirect.

  • Script Editor / Content Editor web page: Edit the web part page and add a script editor web part or content editor web part to add the javascript
  • Directly on the Page: You can edit the page using SharePoint designer 2013 and then you can add the JavaScript or jQuery code to redirect the user to another page in SharePoint.
sharepoint 2013 redirect page to another page
sharepoint 2013 redirect page to another page

Option-1: (Redirect user to another page in SharePoint 2013)

You can write the below script in the source page in SharePoint.

<script language=”javascript” src=”http://code.jquery.com/jquery-1.6.2.min.js”
type=”text/javascript”></script>

<script type=”text/javascript”>
$(document).ready(function(){
window.location = “https://www.enjoysharepoint.com”;
});
</script>

Or you can try below option:

<script language=”javascript” src=”http://code.jquery.com/jquery-1.6.2.min.js”
type=”text/javascript”></script>

<script type=”text/javascript”>
$(document).ready(function(){
window.location.href = “https://www.enjoysharepoint.com”;
});
</script>

Option-2: SharePoint 2013 redirect page to another page

You can also add the below script to redirect page to another page in SharePoint 2013.

<script type=”text/javascript”>
function NavigatetoEnjoySharePoint() {
setTimeout(“location.href=’https://www.enjoysharepoint.com'”, 5000);
}

_spBodyOnLoadFunctionNames.push(“NavigatetoEnjoySharePoint”);

</script>

Option-3: SharePoint online redirect page

You can also write the below code for SharePoint online redirect page.

<script type=”text/javascript”>

// <![CDATA[
alert(“You will be redirected to enjoysharepoint.com now.”);
// ]]>
</script>

<meta http-equiv=”refresh” content=”0;url=https://www.enjoysharepoint.com/”>

Once you save the page and refresh it will redirect. If next time you want to modify, then sometimes you can not because it will redirect very fast. So you can try to access the urls like this:

http://SiteURL/pages/home.aspx?contents=1

Then you can select the particular web part and then you can close or delete the web part. After this, the redirection will stop. This will be helpful more if you have put the code in script or content editor web part. If you have put in the page using designer then you can change the code using the designer.

You may like following SharePoint page tutorials:



Hope this will be helpful for SharePoint 2013 redirect page to another page. You can easily redirect a user from one page to another page in SharePoint Online or SharePoint 2013/2016.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →