views:

442

answers:

1

I already have pdf links set up. I am just looking to prepend Google's syntax in front of my current href using jQuery. i know the following doesn't work, but I feel I am close…?

jQuery(document).ready(function() {
jQuery("a[href$=.pdf]").attr("href", "http://docs.google.com/viewer?url=" + current.href);
});

Can anyway help, please?

A: 

As long as you have absolute urls in the original document the following should work.

$(document).ready(function() {
    $("a[href$='.pdf']").each(function(){
        $(this).attr('href', 'http://docs.google.com/viewer?url=' + $(this).attr('href'));
    });
});​
AdmSteck
thanks admsteck! that's exactly what i was hoping to accomplish.
Scott
after further testing, this method doesn't seem to work with webkit browsers – safari and chrome. ideas?
Scott
Tested using jquery 1.3.2 and 1.4.2 and Google Chrome 4.0 over at [jsfiddle](http://jsfiddle.net/kHj2y/1/)
AdmSteck