I need to put a link to the "Connect to Outlook" script on a SharePoint
2010 page. I have built the stssync:// URL that triggers the Outlook
sync:
stssync://sts/?ver=1.1&type=discussions&cmd=add-folder&base-url=[MyServer]&list-url=[MyList]&guid=[MyGUID]&site-name=[MySiteName]&list-name=[MyListName]
Now the link works fine when pasted in IE address bar. However, I can't add it to a Sharepoint page - if I try to use the "insert hyperlink" button Sharepoint will complain about the stssynch:// protocol "URL must be in the form of http://" (or something to that effect).
I have tried to add a regular link that change the URL by editing the page's HTML. However, Sharepoint removes the link on saving the page.
How can I add the stssync:// link to a page? Is there any simple way to somehow "wrap" it in http or something?
Answer :
Now the link works fine when pasted in IE address bar. However, I can't add it to a Sharepoint page - if I try to use the "insert hyperlink" button Sharepoint will complain about the stssynch:// protocol "URL must be in the form of http://" (or something to that effect).
I have tried to add a regular link that change the URL by editing the page's HTML. However, Sharepoint removes the link on saving the page.
How can I add the stssync:// link to a page? Is there any simple way to somehow "wrap" it in http or something?
Answer :
You can add the following code to a Content
Editor webpart or directly onto the page. After adding the CEWP, in the
ribbon use Editing Tools > Format Text > Edit HTML source.
Code:
Code:
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript">
function replaceURL() {
$('#outlookLink').attr('href','stssync://sts/?ver=1.1&type=discussions&cmd=add-folder&base-url=[MyServer]&list-url=[MyList]&guid=[MyGUID]&site-name=[MySiteName]&list-name=[MyListName]');
}
_spBodyOnLoadFunctionNames.push("replaceURL");
</script>
<a id="outlookLink" href="#">Link to Outlook</a>
Here's what it is doing:- Includes a reference to the jQuery library, which you can either do as in this example or you can download it to your site and include a reference to that location on your site instead.
- replaceURL() uses the jQuery .attr() method to change the href attribute of the anchor tag with the url that you want.
- _spBodyOnLoadFunctionNames.push() will call your function as soon as the page loads.
- Your link should have an id which you refer to in your function. The href can be anything, since it gets modified by your function as soon as the page loads.
No comments:
Post a Comment