Jeremy
Jeremy

Reputation: 46350

Sharepoint links - how to open in new tab/Window

I've noticed with Sharepoint 2010, many of the links do not the support open in new tab/window feature. For example, items on the quick menu do not. Is it possible to enable?

Upvotes: 3

Views: 80168

Answers (7)

user3609778
user3609778

Reputation: 11

For Sharepoint 2013, I used Keith's code with a delayed call.

<script type="text/javascript">
    // Add an entry to the _spBodyOnLoadFunctionNames array
    // so that our function will run on the pageLoad event
    _spBodyOnLoadFunctionNames.push("rewriteLinks");

    function rewriteLinks() {
        $('a').attr("target","_blank");
    }

</script>

Upvotes: 1

Keith Neuse
Keith Neuse

Reputation: 723

This answer is a recap of this article and is not an answer I came up with: http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html

Step 1: Add #openinnewwindow to the end of all hyperlinks you want to open in new window.

Step 2: Then you will need to add the follow script to your SharePoint pages.

[script language = "JavaScript"]

//add an entry to the _spBodyOnLoadFunctionNames array
//so that our function will run on the pageLoad event
_spBodyOnLoadFunctionNames.push("rewriteLinks");

function rewriteLinks() {
  //create an array to store all the anchor elements in the page
  var anchors = document.getElementsByTagName("a");

  //loop through the array
  for (var x = 0; x < anchors.length; x++) {
    //does this anchor element contain #openinnewwindow?
    if (anchors[x].outerHTML.indexOf('#openinnewwindow') > 0) {
      //store the HTML for this anchor element
      oldText = anchors[x].outerHTML;
      //rewrite the URL to remove our test text and add a target instead
      newText = oldText.replace(/#openinnewwindow/, '" target="_blank');
      //write the HTML back to the browser
      anchors[x].outerHTML = newText;
    }
  }
}
[/script]

Upvotes: 3

AUSTX_RJL
AUSTX_RJL

Reputation: 677

In the SharePoint Wiki Editor, you can click the "From Address" Link you added, and a LINK menu will appear in the ribbon bar. Inside that, you can click "Open in New Tab" It's not exactly New Window, but it's close and easy.

Upvotes: 0

Tony Razo
Tony Razo

Reputation: 1

Add this to the end of the link.

#openinnewwindow

example: http://www.bing.com**#openinnewwindow

Upvotes: -3

KRBMRL
KRBMRL

Reputation: 41

Use the JavaScript function to open a new window in SharePoint 2010.

Create the function to open your target window as sample provide below.

function load_url(externallink)
{
    window.open(externallink,target='_blank')
}

Place the function load_url in JavaScript file

Click site actions, select manage content and structure. Suppose you want to change the links in the page http://someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

Then select the List named HelpLinks in the sub site Help. Dev will be the top most node(site). Help will be a sub site and inside Help you can find List by name HelpLinks.

  1. All the links in the page and their title will be displayed

  2. Select the title of link which you want to open in new tab and right click.

  3. Select Edit properties. Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in

Or Else Suppose you want to change the links in the below URL. URL: http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

Go To

  1. open to the link http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx

  2. You will find the columns of the List (Title Column, URL column, Summary etc).

  3. Select the Title and click Edit property which you want to edit

  4. Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in

Upvotes: 4

StevenR
StevenR

Reputation: 396

This is actually an Internet Explorer specific bug. The navigation links in SharePoint 2010 are regular links but have two nested span tags around the text of the link. This confuses IE which doesn't realise that the text you are right-clicking up is a link and so doesn't give the correct context menu. If you right-click just to the left of the text of the link (the cursor should still show as the "hand") the context menu appears as expected.

Upvotes: 1

Ryan
Ryan

Reputation: 24422

Whats the 'Quick menu'? Do mean list item context menu or something else? Can you post a screenshot?

  • There are two types of links used.

  • Normal HTML anchors - You can hold down the CTRL key when clicking.

JavaScript links (menus and such) the CTRL key doesn't work. If you're working with the Edit/View forms then this may be of interest

Especially look for Part II where it talks about changing this behaviour in List Settings > Advanced Settings > Dialogs

Upvotes: 1

Related Questions