Redirect to different page in SharePoint 2013 using JavaScript or jQuery

In this post, we will discuss how we can redirect users to a different page using JavaScript or jQuery in SharePoint 2013. We can see various ways to redirect.

You can also read:
Default breadcrumb for document library SharePoint 2013

How to create a managed path for a web application using PowerShell?

SharePoint 2013 Enhanced or Rich TextBox Validation Using JQuery

Below are a few options you can use to redirect to the different page. Either you can edit the page and put the code inside a script editor web part or you can edit the page using SharePoint designer 2013 and can put the code in the page.

Option-1:
<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:
<script type=”text/javascript”>
function NavigatetoEnjoySharePoint() {
setTimeout(“location.href=’https://www.enjoysharepoint.com'”, 5000);
}

_spBodyOnLoadFunctionNames.push(“NavigatetoEnjoySharePoint”);

</script>

Option-3:
<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 designer.

Hope this will be helpful.


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 →