Scott
Scott

Reputation: 1

Use jQuery to open PDF links with Google Docs

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?

Upvotes: 0

Views: 2729

Answers (1)

AdmSteck
AdmSteck

Reputation: 1761

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'));
    });
});​

Upvotes: 2

Related Questions