Archive for October, 2010

Open SharePoint links in new Window using JQuery

Friday, October 15th, 2010

Today a customer wanted to open some of their links in a SharePoint Links List in a new window. After some googling I found this post. It solved the problem by adding a named achor to the url and then manipulating the all hyperlinks with that anchor using JavaScript. I decieded to do this using JQuery instread.

Below is the code I wrote. Put the script in a content editor web part above the web part showing the links or incorporate it into your master page. Please change the protocol for the jquery script link depending on if you run http or https.

[code lang=”html”]
<script src="" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("a[href$=’#openinnewwindow’]").each(function() {
$(this).attr("target", "_blank");
$(this).attr("href", $(this).attr("href").replace(/#openinnewwindow/, ”));
[/code]">Entries (RSS) and Comments (RSS).