开发者

Use jQuery to open PDF links with Google Docs

开发者 https://www.devze.com 2022-12-26 07:37 出处:网络
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…?

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?


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

精彩评论

暂无评论...
验证码 换一张
取 消