Friday, February 12, 2010

jQuery plugin for social bookmarking

jQuery Bookmark
Description from the site: "The bookmark sharing functionality can easily be added to a div or span with appropriate default settings. The resulting links allow the user to easily post your current page to any number of bookmarking sites."

(I haven't tried this yet, but it looks promising.)

Wednesday, February 10, 2010

Clean up (and expand minified) Javascript

Paste your Javascript code here to get it cleaned up. Can also use it to expand minified code.

[edited 21may2010: Added link to minifier.]

Strict XHTML deprecates "target" attribute

The target attribute of the <a> tag is deprecated in HTML 4.0 Strict and XHTML 1.0 Strict: New-Window Links in a Standards-Compliant World

(Updated 2/12/2010 and 2/24/2010:)
I like the jQuery solution in Justin Scheetz's comment on this article in badlyDrawnToy:

$(function() {
  $("a[href*='http://']:not([href*='"+location.hostname+"'])").click( 

    function() {
      window.open(this.href);
      return false;
  });
});


(Updated again 2/24/2010:)
Here's the jQuery for just setting the target attribute (with a little help from NerdyDork):

$(function() {
$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target", "_blank");
});


(Updated again 10/06/2011:)
Found earlier that the above solution failed for https, so I had to add another line for that.  And then found that the comparison for .hostname needs to be case-insensitive.  So my latest solution is the following, using some tips from the electric toolbox (which also mentions that, with HTML5, "the W3C has un-deprecated the target attribute"):

$(function() { 
  $("a").filter(function() { 
    // find all links that have a hostname 
    // that doesn't match the current location
    return this.hostname && 
      this.hostname.toLowerCase() !== location.hostname.toLowerCase();
  }).click(function() { 
    // open those external links on another window 
    window.open(this.href); 
    return false
  }); 
})



Tuesday, February 9, 2010

Removing the image rollover toolbar on IE6

When you hover over an image on IE6, you'll eventually see a toolbar with 4 buttons: Save this image, Print this image, Send this image in an e-mail, Open My Pictures folder.

Several ways to do it, as described here:
  • Set the galleryimg attribute to "no" on the img tag:
    <img src="blah.jpg" galleryimg="no" />

  • Site wide:
    <!--[if IE 6]>
    <meta http-equiv="imagetoolbar" content="no" />
    <![endif]-->

  • Disable it in the client IE6 browser:
    Internet options > Advanced > Enable Image Toolbar (under Multimedia)


The image toolbar was removed from IE7.