3

Is it possible to get extern links in a list opened in a new windows?
I only found tutorials for SharePoint (Designer) 2010, but I'm using SharePoint 2013 on Office 365.

  • Do you mean links which are available on AllItems.aspx page like link to an item or may be some other? – Asad Refai Jun 16 '15 at 10:04
  • @AsadRefai: No, I mean extern links to other resources (e.g. google.com). – user87238960 Jun 16 '15 at 10:07
0

These solutions stop working if the user filters the view. If I knew the event that happens after the refresh is done (the document does not reloads) I could run this again.

0

I was looking for the same thing and ended up with the following no code solution:

If you have publishing feature enabled, create a site column of "Hyperlink with formatting and constraints for publishing" type and add this Site column in your new list and you'll get the option to open in a new window.

Source with details and screenshots. Hope it helps!

1

Our solution is more simple. If it's an external link, then add a class to the anchor tag

$('a').each(function() {
      if(getHostName($(this).attr('href')) !== 'SiteURL' && getHostName($(this).attr('href')) !== 'AnotherSiteURL') {
                $(this).addClass('external-link');
                $(this).attr('target', '_blank');           }
 });
0

Here is the JavaScript code which you can add in your page so that all external links open in new tab

Make sure to refer jquery reference

<script type="text/javascript" src="jquery"></script>
<script type="text/javascript">
$(document).ready(function(){
 var url = '://' + window.location.hostname;

 // get the current website name, and i add :// to make sure we're looking at the right name
 // in the URL, rules out http://www.google.com/site:wss.domain.com
 url = url.toLowerCase(); // lowercase everything to compare apples to apples
 $("a").each(function() {
 var link = this; // assign the link object to another variable for easier managability
 var linkHref = link.href.toLowerCase(); // lower case it
 if(linkHref.indexOf(url) < 0 && linkHref.indexOf('javascript:') < 0){
 // check to see if this A object has this domain in it and make sure it's not a javascript call
 link.target = '_blank'; // change the target to be in the new window
 }

 if(linkHref.indexOf('.pdf') > 0){ // check to see if this is a PDF
 link.target = '_blank'; // change the target to be in the new window
 $(link).removeAttr("onclick"); //remove the SP click event
 }

 if(linkHref.indexOf('/forms/') > 0 && linkHref.indexOf(').aspx') > 0){
 //check for links in the forms library
 link.target = '_blank'; // change the target to be in the new window
 $(link).removeAttr("onclick"); //remove the SP click event
 }
 });
});
</script>

http://davidlozzi.com/2011/08/09/sharepoint-defaulting-external-links-to-open-in-a-new-window/

  • I did everything explained in this tutorial, but unfortunately I don't see an effect. The hyperlinks in my list still open in the same window, though the script I added is on the site (I can see that in she source code in the browser). – user87238960 Jun 17 '15 at 11:52
  • Can you check on browser console whether any error is coming – Amit Kotha Jun 17 '15 at 12:31
0

Yes. You can. Just create a listview webpart in custom page in which you can have the links you want. And in that page you can add the javascript or jquery to find the anchor tag and add the property target='_blank'. It'll work.

0

Use Summary Links Web Part to open links (internal and external) in new window, without writing a single line of code.

To enable Summary Links Web Part, you will have to enable Publishing feature though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.