使用jQuery打开与Google文档的PDF链接
我已经设置了pdf链接。我只是想用jQuery在我当前的href前面加上Google的语法。我知道下面的方法不管用,但我觉得我很接近 jQuery(document).ready(function() { jQuery("a[href$=.pdf]").attr("href", "http://docs.google.com/viewer?url=" + current.href); }); jQuery(文档).ready(函数(){ jQuery(“a[href$=.pdf]”)attr(“href”http://docs.google.com/viewer?url=“+current.href); });使用jQuery打开与Google文档的PDF链接,jquery,pdf,google-docs,Jquery,Pdf,Google Docs,我已经设置了pdf链接。我只是想用jQuery在我当前的href前面加上Google的语法。我知道下面的方法不管用,但我觉得我很接近 jQuery(document).ready(function() { jQuery("a[href$=.pdf]").attr("href", "http://docs.google.com/viewer?url=" + current.href); }); jQuery(文档).ready(函数(){ jQuery(“a[href$=.pdf]”)attr(“
不管怎样,您能帮忙吗?只要您在原始文档中有绝对URL,以下内容就可以了
$(document).ready(function() {
$("a[href$='.pdf']").each(function(){
$(this).attr('href', 'http://docs.google.com/viewer?url=' + $(this).attr('href'));
});
});
你是说
this.href
而不是current.href
?谢谢admsteck!这正是我希望实现的。经过进一步测试,这种方法似乎不适用于webkit浏览器——safari和chrome。ideas?使用jquery 1.3.2和1.4.2以及Google Chrome 4.0在