MOSS: Add Incoming Links to a Wiki Page with jQuery
Sharepoint’s wiki implementation is rudimentary, but still useful. One of the corners cut in the implementation is that incoming links are on a separate page – you have to click the Incoming Links link (and wait for the screen to refresh) to see them. It’d be much more user-friendly to show these links on the same page as the content.
Turns out with jQuery this is a fairly trivial exercise, at least for a single Wiki page*: Simply add a Content Editor Web part to the page and copy the following code into the Source Editor.
<script type="text/javascript">
$(function() {
//get the url for the incoming links page
u = $("a[id$=WikiIncomingLinks_LinkText]")[0].href;
//create a target container and load it with the incoming links
//filtered to show the links list only
l = $("<div id='incomingLinks' style='border-top: solid 1px silver'>").load(u + " .ms-formareaframe");
//append the new container to the wiki content
$(".ms-wikicontent").append(l);
});
</script>
It may be noted that the above code could even be combined into one single chain – I prefer the above for readability and debugging purposes. Also not sure if I need to dispose of the local variables – this is a POC more than anything else.
The incoming links are now on the page, right below the content:
A more thorough implementation might position the links in a box in the upper left corner, and simultaneously removing the “Incoming Links” link.
*I haven’t quite thought out how to inject this throughout a wiki. Any suggestions?
Labels: experiment, javascript, jquery, moss, programming, sharepoint, wiki