使用 jQuery 通过 Google 文档打开 PDF 链接

发布于 2024-08-27 09:56:33 字数 250 浏览 3 评论 0原文

我已经设置了 pdf 链接。我只是想使用 jQuery 在我当前的 href 前面添加 Google 的语法。我知道以下不起作用,但我觉得我很接近......?

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

无论如何可以帮忙吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2024-09-03 09:56:33

只要原始文档中有绝对网址,以下内容就应该有效。

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

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'));
    });
});​
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文