jQuery: Plugins

Found an extensive list of jquery-plugins through Web 2.0 Technologies: jQuery plugin goodness.

What really pleased me was that I found a higlight/fade addon for jquery (like Fade Anything Technique, Yellow Fade Technique and more).

I have told my self that I must write a generic solution for fading as a plugin to jquery, but I never seem to find the time. The highlightFade script for jquery is not yet fully documented but it should not be any problem implementing it by reading the inline-documentation in the source-code.

Rewrite and log links with jQuery

I log and rewrite my outgoing links with jquery. I do this for a couple of reason:

  1. I want to have valid XHTML, and not add target to my links in the markup.
  2. I want Google to index my outbound links correctly and not have mysterious links like /link/out.php?url=http://www.yahoo.com.
  3. I want the sites that i link to, to see the correct referrer in their logs.
  4. I still want to log what links are popular exits from my page

How do I solve this?

  1. Add a class to each external link I want to log.

    Yahoo!
  2. Attach a log and a rewrite behaviour to links with the class added above.
    
    $(document).ready(function(){
      $("a.external-link").each(function(){
         //rewrite: open in new window
         this.target = "_blank";
         //log the click
         this.onclick = function(){
           //lets make some valid use of xmlhttp-capabilities
           $.get("/out.php?url=" + escape(this.href), function(s){});
         }
      });
    }
    );
    
    
  3. Create the server-side controller for handling logging.
    
    out.php
    
    
    

That should more or less do it.

  1. We still have valid strict xhtml
  2. The outbound links are unaltered in a Search Engine Optimization point of view
  3. Referring links are correct for those sites that we do link to
  4. We are able to log outbound links