Creating a ‘Bookmark’ button in SharePoint

If you are familiar with SharePoint Portal 2007 you will be aware that there is now the ability to have your own personalized list of links (‘My Links’) which you can share with everyone, just certain colleagues or even for yourself. Using the ‘My Links’ button in your navigation you can easily get to these links, and also add a new link.

What I discovered today though was how you can impersonate the ability to add a new link to this list – as you might want to add a link on certain (or even every) page. This gives users the ability to click ‘bookmark’ or ‘add to my links’ easily. The link is then added to their own personal links – essentially building up their own favourites within SharePoint.

The client script responsible for helping out here is AddToQuickLinksDialog(templateId, baseUrl). If you add this into a control you then will be able to harness all the power of the ‘My Links’ control from where ever you like in your portal – including the control identifying the url that you are on and adding this into your link.

So for example to create a button for bookmarking any page, you would simply add the following into your masterpage:

<asp:Button OnClientClick="AddToQuickLinksDialog('thisbutton','http://SharePointURL/');" 
                                runat="server" ID="thisbutton" Text="Bookmark this page!"></asp:Button>
This entry was posted in SharePoint. Bookmark the permalink.

4 Responses to Creating a ‘Bookmark’ button in SharePoint

  1. Unknown says:

    To add the bookmark to search results page include this anchor and the following javascript in XSLT<a href="javascript:BookmarkThisResult(\’{title}\’,\’{$url}\’)">Bookmark</a><script language=javascript>function BookmarkThisResult(shortname, resulturl){    var loc = document.location.href;    var baseUrl = loc.substring(0,loc.lastIndexOf("/"));   var args = new Array();   args[0] = shortname;   args[1] = resulturl;   args[2] = \’\’;   var features = \’resizable=no,status=no,scrollbars=yes,menubar=no,directories=no,location=no,width=750,height=475\’;   if (browseris.ie55up)      features = \’resizable: no; status: no; scroll: yes; help: no; center: yes; dialogWidth:750px; dialogHeight: 475px;\’;   commonShowModalDialog( \’/_layouts/QuickLinksDialog.aspx\’, features, null, args);}</script>

  2. Nick Larter says:

    I have added your button code to my masterpage, however I get a JavaScript error on the following line of QuickLinksDialog2.aspx whilst the dialog window is initialising:

    var form = document.forms[0];
    var args = window.parent.frameElement.dialogArgs;

    The window.parent.frameElement appears to be null.

    I am using SharePoint 2010 so the HTML of the dialog windows could have changed somewhat. Do you have any ideas what might be cuasing this error?

  3. Pingback: SharePoint 2010: Create a bookmark button that adds a page to your My Links

  4. Pingback: Adding to My Links | donnelly does development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s