Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery打开与Google文档的PDF链接_Jquery_Pdf_Google Docs - Fatal编程技术网

使用jQuery打开与Google文档的PDF链接

使用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(“

我已经设置了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); });
不管怎样,您能帮忙吗?

只要您在原始文档中有绝对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在