Tuesday, December 2, 2014

How to change the Web Part Title URL behavior

With my morning cup of coffee I decided to start with something fairly simple (as a requirement) - it's in fact quite fresh as I had to do it for a client yesterday. It sounded like a 5 minute job, at the end it turned out more interesting. I've done this on 2010 and tested on 2013 as well - same behavior.

The requirement is to make just one specific webpart title URL to open in a new window while keeping all others (if any) loading in the same browser window. I am referring to the "Title URL" property, that is set in the Advanced section when you edit the web part.


There's no out of the box option to configure that, you could remove the URL, or point it to the page itself by changing it to #, but no way to make it open in a new window by adding "_blank" or something.

We can, however use a tiny piece of JavaScript to achieve that (tell SharePoint to do a specific thing when someone clicks on a specific URL) and we have a couple of options doing that thanks to jQuery.

Depending on whether that webpart is reused in many sites or web apps, you need to decide which method is the right one for you, You can do it globally with a full trust solution. That would have a wide impact on all web apps that have the solution deployed.
Let's assume you already have some branding solution in place which has a ccustomizations file in a .js format, you can add that piece of code in there. We are using the onload function here to ensure the site has fully loaded. If you have other JavaScript / jQuery customizations in the site that's the preferred method of calling jQuery to avoid any conflicts. The downside is that it will load only after all images are fully loaded, including some banner ads, etc.

In those example scripts I'm using the Microsoft CDN hosted version of the jQuery library, you can, however download a copy and store it locally on your site. Please make sure you use the https:// prefix in the reference if your site is accessed through SSL.

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"</script><script>
window.onload = function() {
    if (window.jQuery) {
        jQuery(document).ready(function () {
                                jQuery('a[href^="http://www.contoso.com (replace with your URL)"]').click(function () {
                                jQuery(this).attr("target", "_blank");
                                });

                });
 </script>

The second way (more granular) is to store the script as a .js file in SharePoint and apply that on the page level by using the Content Editor webpart to call it. Here we're using the statement known as the ready event. This ensures that the code will run as soon as the document is ready for manipulation. Preferred method if we don't experience any conflicts with other customizations when trying to load it that way. Executes straight away without loading all the images first.

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"</script><script>
$(document).ready(function(){
  $('a[href^="http://www.contoso.com (replace with your URL)"]').click(function() {
    $(this).attr("target","_blank");
  });
});
 </script>

You can also do that for all web part title URLs, the script will look like this:

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"</script><script>
$(document).ready(function(){
$("h3.ms-WPTitle a").attr("target","_blank");
 });
 </script>

That's it. You can then export/import your CEWP and reuse it on any other page quickly. Don't forget to set its Chrome type to None so you don't actually display it on the web page.

84 comments:

  1. Not able to get this to work. My ExcelWebpart is on a WebPart page, single column. Tried placing it in page itself, placing code in Content Editor and calling code from Content Editor. Nothing has worked

    ReplyDelete
    Replies
    1. Hi James,

      Thanks for your comment.

      Please try and save one of the scripts as a .js file and upload it to your SharePoint farm. Ideally in the same site collection where it will be loaded. Then call it from a Content Editor Web part.

      If that does not work, use Developer Tools in your browser to see if the .js is trying to load at all.
      Might be wrong method of calling it, or a setting in the browser (much less likely though).

      Cheers,

      Dimitar

      Delete
    2. Excellent web site you have here.. It’s hard to find good quality writing like yours these days. I truly appreciate individuals like you!
      Debt Consolidation lawyer in Ontario

      Delete
  2. We have a well-defined process and a dedicated team that will keep you well informed before every step we take. We make sure to get you the top quality website that result in more quality leads and sales. web development services in usa

    ReplyDelete
  3. You must indulge in a contest for one of the greatest blogs over the internet. Ill suggest this web site! design agency san francisco

    ReplyDelete
  4. This plot doesn’t reveal itself; it has to be explained. web design san francisco

    ReplyDelete
  5. Awesome post, will be a daily visitor from now on! design firms los angeles

    ReplyDelete
  6. I’m curious to find out what blog platform you are utilizing? I’m experiencing some small security issues with my latest blog and I would like to find something more safe. Do you have any solutions? web design agency los angeles

    ReplyDelete
  7. Along these lines, despite the fact that you have your site place under system uptime you may be 100% safe.web hosting near me

    ReplyDelete
  8. cleaning supplies should have earth friendly organic ingredients so that they do not harm the environment“ web design la

    ReplyDelete
  9. I dont think Ive scan anything like this before. So good to find somebody with some original thoughts on this subject. nice one for starting this up. This site is something that is needed on the web, someone with a little originality. Good job for bringing something new to the internet! website design

    ReplyDelete
  10. Yay google is my world beater helped me to find this great web site ! . web design tips

    ReplyDelete
  11. It’s appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I wish to suggest you some interesting things or tips. Maybe you could write next articles referring to this article. I wish to read more things about it! top web design companies

    ReplyDelete
  12. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. SEO Company Vancouver

    ReplyDelete
  13. Promptly this kind of extraordinary internet site must unquestionably become identified inside of every one of the web site a lot of people, as a result of meticulous posts or perhaps critiques or perhaps comments. web design companies denver

    ReplyDelete
  14. This is precarious since, supposing that your lone promoting will be Natural Pursuit/PPC you may need a watchword spam type area name. Webdesign

    ReplyDelete
  15. It is important to draw a line between work time and relaxation time, saving certain pieces of the day for working and certain parts to manage different duties. On the off chance that no line is drawn, you'll discover little tasks: 'making the children a bite', 'rushing to the shops', 'browsing your messages', take up an enormous segment of the day. The appropriate response is to make an everyday practice for your independent work: have similar segments of the day put in a safe spot for work, plan sensible breaks and adhere to the arranged completing time.Professional graphic design

    ReplyDelete
  16. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. web-agency

    ReplyDelete
  17. I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. creare sito ecommerce

    ReplyDelete
  18. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. creare sito web

    ReplyDelete
  19. It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. online customer service outsource

    ReplyDelete
  20. This is a framework of what we expect soon to the extent SEO business is of concern.
    Website laten maken

    ReplyDelete
  21. Another central issue you ought to characterize is whether the web designer can make you a 100% custom web website. Webdesign Genk

    ReplyDelete
  22. This blog is really great. The information here will surely be of some help to me. Thanks!. 웹툰 다시보기

    ReplyDelete
  23. I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. Webdesign Antwerpen

    ReplyDelete
  24. Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work. Webdesign bureau

    ReplyDelete
  25. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. WordPress Developer Brisbane

    ReplyDelete
  26. There are a few sorts of websites like Internet business destinations, online media locales, layout based destinations, CSS websites and a few more. Webdesign-seo-limburg.be

    ReplyDelete
  27. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home.
    คลินิกเสริมความงาม

    ReplyDelete
  28. When you want to have a website for your small business, the best way is to get it designed by a professional web design company. However, you need to look at a few factors before selecting the company to do the job for you. It is a good idea to see what they are. Social Media Creation, Design, Management and Optimisation

    ReplyDelete
  29. Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards,
    토토사이트

    ReplyDelete
  30. Your blog has piqued a lot of real interest. I can see why since you have done such a good job of making it interesting. I appreciate your efforts very much. convert pdf to docx

    ReplyDelete
  31. Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
    Aplikasi saham rekomendasi

    ReplyDelete
  32. I'll come often. I hope you prosper.Please write good things from now on. 먹튀신고

    ReplyDelete
  33. I'm surprised there's such a wonderful article.every pressured me to take a look at and do it 토토사이트

    ReplyDelete
  34. He's growing up. It's growing. That's a really good piece of data. Amazing. 메이저사이트

    ReplyDelete
  35. Your blog is fabulous, superior give good results... Seen a large number of definitely will understand everybody even in the event they do not take the time to reveal.
    refomas baños zaragoza

    ReplyDelete
  36. This is one very interesting post. I like the way you write and I will bookmark your blog to my favorites.메이저놀이터

    ReplyDelete
  37. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts.먹튀검증사이트

    ReplyDelete
  38. Keep up the good work , I read few posts on this web site and I conceive that your blog is very interesting and has sets of fantastic information. 먹튀사이트

    ReplyDelete
  39. I really like your writing style, great information, thankyou for posting. แทงบอล i99pro

    ReplyDelete
  40. Cool stuff you have got and you keep update all of us. 안전놀이터

    ReplyDelete
  41. You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. 안전놀이터

    ReplyDelete
  42. This is actually the kind of information I have been trying to find. Thank you for writing this information. 온라인릴게임

    ReplyDelete
  43. Thanks for sharing your wealthy information. This is one of the excellent posts which I have seen. I go through your all of your blog, but this blog is the best one. It is really what I wanted to see hope in future you will continue for sharing such an excellent post
    mở lại đường bay việt nam - hàn quốc

    lịch bay từ úc về việt nam hôm nay

    vé máy bay từ san francisco về việt nam

    Vé máy bay từ Đài Trung về Việt Nam

    có vé máy bay từu mỹ về việt nam chưa

    khi nào có chuyến bay từ canada về việt nam

    ReplyDelete
  44. Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. 토토사이트

    ReplyDelete
  45. Thank you so much as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC. 팔팔카

    ReplyDelete
  46. Our final recommendation is a pretty obvious and simple one, to most people, but we still speak to developers who don't use any form of source control. https://www.sandeepmehta.co.in/affordable-seo-services-delhi/

    ReplyDelete
  47. What is an outstanding post! “I’ll be back” (to read more of your content). Thanks for the nudge! 대전건마

    ReplyDelete
  48. Online achievement of your website relies upon preparing and executing our "add unique quality substance frequently" procedure alongside these custom CMS web design spending tips.
    https://onohosting.com/

    ReplyDelete
  49. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks สมัครงาน คลินิกเสริมความงาม

    ReplyDelete
  50. Fabulous post, you have denoted out some fantastic points, I likewise think this s a very wonderful website. I will visit again for more quality contents and also, recommend this site to all. Thanks. nursing test bank

    ReplyDelete
  51. At Inovi, we’re committed to achieving the highest success rates while providing personalized care to our patients. Our Houston location offers expert care and is home to our state-of-the-art embryology lab. click reference

    ReplyDelete
  52. With liposuction, the surgeon can remove stubborn fat deposits, improve your physical appearance by using contouring procedures to give you pleasing curves in all the right places. Look At This

    ReplyDelete
  53. Great content material and great layout. Your website deserves all of the positive feedback it’s been getting. 대전마사지

    ReplyDelete
  54. Nice blog, I will keep visiting this blog very often. 대전1인샵

    ReplyDelete
  55. Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. 바둑이

    ReplyDelete
  56. your content is very inspiring and appriciating I really like it please visit my site for Satta King Result also check Satta king 24X7 and also check sattaking and for quick result check my site Satta matka and for super fast result check Satta king ohttp://sattavipkingg.moonfruit.com/r delhi satta king

    ReplyDelete
  57. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! 꽁머니 사이트 추천

    ReplyDelete
  58. Wow, excellent post. I'd like to draft like this too - taking time and real hard work to make a great article. This post has encouraged me to write some posts that I am going to write soon. Joker123

    ReplyDelete
  59. You have a real talent for writing unique content. I like how you think and the way you express your views in this article. I am impressed by your writing style a lot. Thanks for making my experience more beautiful. 메이저사이트

    ReplyDelete
  60. I can’t believe focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material without a doubt. It is one of the greatest contents. 오피사이트

    ReplyDelete
  61. Mario is a fictional character in his eponymous video game series which was created by the Japanese video game designer Shigeru Miyamoto. Since his creation and serving as Nintendo's mascot Mario has appeared in over 200 video games. Though it originally only appeared in platform games. twitch viral

    ReplyDelete
  62. Thanks for providing recent updates regarding the concern, I look forward to read more. 먹튀폴리스

    ReplyDelete
  63. Superheroes battle monsters and space invaders in fast action games. Players take on the role of these superheroes in epic battles. In other games players race cars, boats, motorcycles, helicopters and planes against villains and even less evil opponents to win high stakes races. Game titles such as Burnout3: Takedown, ESPN, NHL - 2K5, Silent Hill 4: The Room, Terminator 3: The Redemption, Donkey Kong 3, and, Pokemon have joined the national lexicon as kids have flocked to the lure of electronic games. https://www.buyyoutubesubscribers.in/

    ReplyDelete
  64. It's consistently desirable over select an incredible web design organization that involves committed and prepared workers.
    MavericksMedia

    ReplyDelete
  65. If you are introducing a novel website or attempting to renew the ex site for enhanced client coverage, nothing can be better than obtaining proficiently excelled web services. A niche web site design provider will always initially talk about your business, needs and clients instead of site service catalogue. Web Design Company Toronto

    ReplyDelete
  66. Harmless to the ecosystem web facilitating is getting increasingly more well known for business web destinations seeming to execute an eco-strategy. check out my patreon

    ReplyDelete
  67. Cause of Arthritis… [...]while the sites we link to below are completely unrelated to ours, we think they are worth a read, so have a look Professional Video Presentation Service

    ReplyDelete
  68. Is it possible to monetize on a Flash games website? Why this internet money making idea may not be such a good one. buy twitch followers

    ReplyDelete
  69. An extremely magnificent blog entry. We are extremely thankful for your blog entry. battle, law authorization You will discover a ton of methodologies in the wake of going by your post. I was precisely looking for. A debt of gratitude is in order for such post and please keep it up. Awesome work antminer L7

    ReplyDelete
  70. an impressive share! I’ve surely forwarded this onto a co-worker who have been doing a little research on this. And he in fact ordered me dinner because of the reality i found it for him… lol. So allow me to reword this…. Thanks for the meal!! However yeah, thanx for spending the time to talk approximately this undertaking right here for your blog. Your style may be very specific in comparison to different human beings i've look at stuff from. Thank you for posting if you have the opportunity, bet i'm capable of truly e-book mark this website online. Right positioned up. I examine a few factor new and tough on web websites i stumbleupon ordinary. It’s continually exciting to look at content material from unique writers and use some thing from other web sites. 먹튀검증

    ReplyDelete
  71. pinnacle day! I may additionally need to have sworn i’ve visited this web site earlier than but after searching at the various posts i realized it’s new to me. Regardless, i’m absolutely happy i came at some stage in it and that i’ll be bookmarking it and checking lower back often! After looking right into a handful of the blog articles on your net web site, i clearly recognize your way of writing a blog. I saved it to my bookmark internet website list and may be checking decrease returned quickly. Take a look at my internet site too and allow me recognise the manner you experience. Hi there! This blog put up couldn’t be written plenty better! Looking through this post jogs my memory of my preceding roommate! He continuously saved preaching about this. I am going to beforehand this facts to him. Pretty certain he ought to have a super study. Thank you for sharing! 먹튀검증놀검소

    ReplyDelete
  72. exceptional submit. I study something new and tough on websites i stumbleupon everyday. It will usually be beneficial to study thru content material from other authors and use a touch some thing from other web sites . This is absolutely fascinating, you are a very professional blogger. I've joined your feed and appearance ahead to within the hunt for greater of your great post. Additionally, i've shared your net web page in my social networks . I discovered your blog the use of msn. This is a really nicely written article. I'm able to be sure to bookmark it and go back to read extra of your useful facts. Thanks for the submit. I will genuinely go back. You are incredible! Thanks! You are so interesting! I do now not consider i have examine thru some thing like that before. So great to discover another person with some precise thoughts on this difficulty. Virtually.. Thank you for beginning this up. This internet site is one thing this is wished on the internet, a person with a chunk of originality! Manner cool! Some extraordinarily legitimate points! I recognize you writing this text and also the rest of the internet site is brilliant. Its such as you study my mind! You appear to know a lot about this, like you wrote the e-book in it or something. I suppose that you can do with some snap shots to force the message domestic a little bit, but apart from that, that is first rate blog. A fantastic examine. I will simply be lower back. 먹튀폴리스

    ReplyDelete
  73. you are so interesting! I don’t don't forget i’ve study a few factor like this before. So terrific to discover every other man or woman with some right mind in this issue. Significantly.. Thank you for beginning this up. This internet site is some thing this is required on the net, a person with a few originality! I pretty like reading thru a post which could make men and women count on. Additionally, many thanks for allowing me to comment! Spot on with this write-up, i in reality think this splendid net website wishes a super deal extra interest. I’ll likely be returning to peer extra, thank you for the advice! I’m very thrilled to discover this web page. I desired to thank you for your time for this terrific study!! I virtually simply favored each little little bit of it and i additionally have you ever stored as a favorite to have a examine new matters to your internet web page. 토토디펜드

    ReplyDelete
  74. thank you for this kind of incredible weblog. Where else could all people get that kind of information written in such a ideal way? I've a presentation that i am presently writhing on, and i have been on the appearance out for such fantastic records. . Exceptional blog right here! Additionally your internet web page hundreds up rapid! What host are you using? Can i am getting your associate hyperlink on your host? Pretty section of content. I just stumbled upon your weblog and in accession capital to claim that i am getting definitely enjoyed account your blog posts. Thanks for the put up and terrific hints: even i additionally think that tough work is the maximum crucial issue of getting fulfillment. 온라인바카라

    ReplyDelete
  75. hello! I simply wish to deliver a sizeable thumbs up with the first-rate statistics you could have right right here for this publish. I am returning to your weblog for more quick. Have you ever ever concept about writing an e-book or tourist authoring on one-of-a-kind web sites? I've a blog centered at the same mind you speak and would really like to have you ever percent some memories/statistics. I apprehend my target marketplace could enjoy your work. If you are even remotely interested, sense free to shoot me an e mail. Wow!, this become a top pleasant post. In idea i’d like to publish like this as well – taking time and real attempt to make a pleasant article… but what am i in a position to mention… i keep placing it off and by no means seem to get some factor done 바카라

    ReplyDelete
  76. Thank you for shearing post amazing this is post very useful for me.
    New Media
    New Media
    New Media
    New Media
    New Media
    New Media
    New Media
    New Media

    ReplyDelete
  77. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... Web Design Melbourne

    ReplyDelete
  78. Nice blog, I will keep visiting this blog very often. 먹튀검증커뮤니티

    ReplyDelete
  79. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Apply for Work Permit in Canada

    ReplyDelete