Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Created October 15, 2010 05:22
Show Gist options
  • Save addyosmani/627670 to your computer and use it in GitHub Desktop.
Save addyosmani/627670 to your computer and use it in GitHub Desktop.
/* View documents with Google Docs ...
* because my laptop can't handle Word and Chrome at the same time. */
$(document).ready(function(){
// I'm sure there's a more efficient selector for this.
$('a[href$=doc], a[href$=docx], a[href$=pdf], a[href$=rtf]').attr(
'href',
function(){
return 'http://docs.google.com/viewer?url=' + this.href;
}
)
.attr(
'target',
'_blank'
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment