1,804 articles and 15,135 comments as of Sunday, May 15th, 2011

EndUserSharePoint has combined resources with NothingButSharePoint.com. You can now find End User (Mark Miller), Developer (Jeremy Thake) and IT Pro SharePoint content all in one place!

This site is a historical archive and is no longer being updated. Please update your favorites, bookmarks and RSS feeds.

NothingButSharePoint.com
Tuesday, December 16, 2008

JQuery for Everyone: Dressing-up Links Pt1

We had a request from Ari in our last installment of JQuery for Everyone!  Ari wants to know how to add fancy “this is an external linkicons to his page.  Since that was basically written for me by Karl Swedberg at Learning jQuery, I decided to take it up a notch (using some AJAX and JSON tricks).

But, if you only need the external link icons:

  • Add jQuery to your page (see previous article for different methods)
  • Download a good icon (WSS doesn’t seem to have a good one)
  • Add the icon to your server (document library or the 12\TEMPLATE\IMAGES directory)
  • Place the following script on your page (replacing the image path with your own)

<script type="text/javascript">
$(function() {
  $('a').filter(function() {
	return this.hostname && this.hostname !== location.hostname;
  }).after(' <img src="/PaulGrenier/images1/external.png" alt="external link">');
});
</script>

If you want to do more with this idea, of dressing up links, come back tomorrow and I’ll show you how to add the file size for those external links.

View all entries in this series: PaulGrenier-JQuery for Everyone»
Entries in this series:
  1. JQuery for Everyone: Accordion Left Nav
  2. JQuery for Everyone: Print (Any) Web Part
  3. JQuery for Everyone: HTML Calculated Column
  4. JQuery for Everyone: Dressing-up Links Pt1
  5. JQuery for Everyone: Dressing-up Links Pt2
  6. JQuery for Everyone: Dressing-up Links Pt3
  7. JQuery for Everyone: Cleaning Windows Pt1
  8. JQuery for Everyone: Cleaning Windows Pt2
  9. JQuery for Everyone: Fixing the Gantt View
  10. JQuery for Everyone: Dynamically Sizing Excel Web Parts
  11. JQuery for Everyone: Manually Resizing Web Parts
  12. JQuery for Everyone: Total Calculated Columns
  13. JQuery for Everyone: Total of Time Differences
  14. JQuery for Everyone: Fixing Configured Web Part Height
  15. JQuery for Everyone: Expand/Collapse All Groups
  16. JQuery for Everyone: Preview Pane for Multiple Lists
  17. JQuery for Everyone: Preview Pane for Calendar View
  18. JQuery for Everyone: Degrading Dynamic Script Loader
  19. JQuery for Everyone: Force Checkout
  20. JQuery for Everyone: Replacing [Today]
  21. JQuery for Everyone: Whether They Want It Or Not
  22. JQuery for Everyone: Linking the Attachment Icon
  23. JQuery for Everyone: Aspect-Oriented Programming with jQuery
  24. JQuery for Everyone: AOP in Action - loadTip Gone Wild
  25. JQuery for Everyone: Wiki Outbound Links
  26. JQuery for Everyone: Collapse Text in List View
  27. JQuery for Everyone: AOP in Action - Clone List Header
  28. JQuery for Everyone: $.grep and calcHTML Revisited
  29. JQuery for Everyone: Evolution of the Preview
  30. JQuery for Everyone: Create a Client-Side Object Model
  31. JQuery for Everyone: Print (Any) Web Part(s) Plugin
  32. JQuery for Everyone: Minimal AOP and Elegant Modularity
  33. JQuery for Everyone: Cookies and Plugins
  34. JQuery for Everyone: Live Events vs. AOP
  35. JQuery for Everyone: Live Preview Pane
  36. JQuery for Everyone: Pre-populate Form Fields
  37. JQuery for Everyone: Get XML List Data with OWSSVR.DLL (RPC)
  38. Use Firebug in IE
  39. JQuery for Everyone: Extending OWS API for Calculated Columns
  40. JQuery for Everyone: Accordion Left-nav with Cookies Speed Test
  41. JQuery for Everyone: Email a List of People with OWS
  42. JQuery for Everyone: Faster than Document.Ready
  43. jQuery for Everyone: Collapse or Prepopulate Form Fields
  44. jQuery for Everyone: Hourly Summary Web Part
  45. jQuery for Everyone: "Read More..." On a Blog Site
  46. jQuery for Everyone: Slick Speed Test
  47. jQuery for Everyone: The SharePoint Game Changer
  48. JQuery For Everyone: Live LoadTip
 

Please Join the Discussion

11 Responses to “JQuery for Everyone: Dressing-up Links Pt1”
  1. Ari says:

    Thanks Paul, works fine and just the thing I wanted.

  2. Cool article, I’ve also modified your script slightly to work around the annoying problem of not being able to open external links in a new window from within the Quick Launch (WSS not MOSS)!

    Slightly hacky, but works none the less!

    Steve.

  3. AutoSponge says:

    That’s the kind of creativity I like to see :)

    Overcome the annoyances of the UI. If you have ext links in your nav, you may want to replace my “file not found” with an icon when you get to pt-3 of this series:
    http://www.endusersharepoint.com/?p=1043

  4. JohnnyM says:

    Simple! Thank You Paul.
    Question: Is there a way to skip running this for certain web parts?
    For instance, I have a page I want ot use this on but there is a calendar opened up on the page and all the utility links on the Cal get that image tagged to the link, like prev and next month links.
    How can I skip that Webpart? I tried adding a conditional but thats not working:

    if $(”div:contains(’WebPartWPQ6′)”) {
    return;
    }else{
    $(’a').filter(function() {
    blah blah blah

Trackbacks

Check out what others are saying about this post...
  1. SharePoint Kaffeetasse #98…

    Tools und Addons Custom Content Editor Web Part for SharePoint jQuery http://jquery.com/ jQuery is a…

  2. SharePoint Kaffeetasse #98…

    Tools und Addons Custom Content Editor Web Part for SharePoint jQuery http://jquery.com/ jQuery is a…

  3. [...] part 1, we added some nifty icons to external links. However, because we only compared the anchor’s [...]

  4. German Blogs says:

    SharePoint Kaffeetasse #98…

    Tools und Addons Custom Content Editor Web Part for SharePoint jQuery http://jquery.com/ jQuery is a…

  5. OneOfSix says:

    Add Links to SharePoint Wiki Toolbar using jQuery…

  6. [...] found the article from Paul Grenier concerning managing external links so compelling that I packed up a web part for use on sites. Here are the [...]




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!