Wednesday 9 November 2011

Redirect a SharePoint site by using the Content Editor Web Part

At some point in time you might want to point users to another location from a specific page and prompt them before doing so. I will show you how to do this using the Content Editor Web Part. It is rather easy. First, you must have proper permissions on the page or site that you are trying to redirect users. Second, be advised that this may not be best practice to use the CEWP. For my situation, I needed a way to direct users from a page without actually moving or deleting the page. This worked great for my needs, yours may be different. Anyways here we go:
  1. First click Site Actions > Edit Page in the top right section of your browser window. Now MOSS will effectively checkout the page in your account name.
  2. Next we are going to add the Content Editor Web Part to a zone of your choice; it doesn't really matter since users won't be using the page. This is done several ways, let's just click on the Add a Web Part button ontop of the zone you chose.
  3. This will bring up the Add a Web Part window. Scroll down to the Content Editor Web Part.
  4. This will place the CEWP into the Top Zone or whichever zone you added it to. Let's modify the web part. This is done by clicking Edit > Modify Shared Web Part.
  5. Once we have clicked the modify button a window opens on the right hand side of the browser with various options for the web part. We want to add our code the webpart so we will click the Source Editor... button.
  6. Good, almost done... we just need to copy and paste the following code:
1<SCRIPT type='"text/javascript"'>// <![CDATA[
2alert("This site has been moved to another location, please update all existing bookmarks.  You will be redirected momentarily.");
3// ]]></SCRIPT>
Into the Source Editor Windows that pops up when we clicked the Source Editor... button.
Great! Now all you have to do is click the Save button, publish the page and your done. Users who navigate to this page will be greeted with a popup and redirected in 10 seconds (the default time). Please note: If you want to change the amount of time before the redirect simply change the number of seconds by editing the following number representing the time lapse:
<meta http-equiv="refresh" content="10;url=http://MYSERVERNAME.com/Pages/default.aspx
 

No comments:

Post a Comment