Link Redirection Using JQuery In SharePoint

Published by Prateek Mangal on

In SharePoint, developer can manage Link Redirection feature without any Redirection Service or DNS modification.

You need to implement client side script and put it into applied master page of old SharePoint site. Using this script all user will be redirected from Source site to Target site or you can say from old SharePoint site to new SharePoint site.

Below is the script which you can put into <head></head> element of your Master Page.

<script> $(location).attr('href', 'Target Site URL');  </script>
There are few challenges by simply applying this script into your Master Page.
  • During redirection user will not see any message. Hence, screen should display a notification or message before redirection.
  • Link Redirection will not allow developer to open old site. For e.g. after Go-Live any issue comes and developer needs to login into old system with enabled Link Redirection. Hence, a logic is required to identify logged in user is developer or end user.

We are handling these situation with help of CSS/JQuery and SharePoint Group.

Configuration

Follow below steps for implementing this script :

Step1 :  Create a SharePoint group in old site with any name for e.g. ‘Legacy User Group’ and note down it’s group id.  For e.g. in below code, Id of Legacy User Group  is ‘329’.  Please add those user who will see old site after link redirection. See line no. 12.

Step2 : Change setting ‘who can view membership of the group’ to Everyone. Please click here to see how to change this setting.

Step3 : Insert new site url into <script> tag . See line no. 20.

Step4 : Download existing master page and change its name. For e.g. ‘PreviousName_LR.master’ 

Step5 : Add content  of <style> and <script> tags from below code to your master page which you renamed in above step.

Step6 : Upload a loader gif image into any library of old SharePoint site and change its URL into master page <style> tag which we just added in above step.  See line no. 4.

Step7 : Provide id=”loading” attribute property to <body> tag of your master page and save master page. See line no. 76.

Step8 : Upload master page to master page gallery and apply this new master page from master page setting.

 1,452 total views,  1 views today

Care to Share?

Prateek Mangal

7 Years Experienced Information Technology Professional with a demonstrated history of working in the information technology and services industry. Skilled in SharePoint, Power App, Power Automate, Power BI, SQL, CSS, .NET, HTML, and REST API. 

1 Comment

Anit Sinha · June 11, 2018 at 12:54 PM

This is quite useful article. Well explained !!

Leave a Reply