Google文档查看插件(jquery)

原文来自: http://www.jawish.org/blog/archives/394-Google-Docs-Viewer-plugin-for-jQuery.html


Google Docs Viewer plugin for jQuery


Here's a little jQuery plugin I wrote recently that automatically embeds the Google Docs Viewer for viewing pdf, doc, docx, ppt and tiff files linked to by anchor tags.


The Google Docs Viewer is an embeddable browser-based viewer that requires only a URL to a file available online. This neatly bypasses the need for users to have compatible software on their machines for those file types and displays the document right in the browser.

Usage


1. Add jQuery and the gDocsViewer plugin to the page.
1. <head>
2. <scripttype="text/javascript"src="jquery.min.js"></script>
3. <scripttype="text/javascript"src="jquery.gdocsviewer.min.js"></script>
4. </head>

2. Set some class name or id to the anchor tag for all URLs to files that you want to be displayed using the Google Docs Viewer. E.g. "embed"
1. <ahref="urltofile.pdf"class="embed">Download file</a>
1. <ahref="urltofile.pdf"id="embedURL">Download file</a>

3. Initialize gDocsViewer and set it to process the URL with id or all URLs with the class name set in the previous step.
1. $('a.embed').gdocsViewer();
1. $('#embedURL').gdocsViewer();

Customization


The plugin offers two configuration options that set the width and height of the embedded document IFRAME. This can be set when the plugin is initialized.
1. $('a.embed').gdocsViewer({ width: 400, height: 500 });

The plugin inserts a the IFRAME for the viewer inside an injected DIV. The DIV tags all carry the class name "gdocsviewer", which allow for styling all the gdocsViewer instances via CSS. If the anchor tag has the ID attribute defined, then the injected DIV tag is also set an ID attribute in the format of ID_of_Anchor + '-gdocsviewer'. See the demo source code for more details.

Demo


- Check out the live demonstration

License

This script is released under the Open Source MIT License, allowing its use in both personal and commercial applications as long as the copyright and license permission notice remains intact.

Download

- jquery.gdocsviewer.v1.0.zip (v1.0, 2.2KB)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PyCharm是一个流行的Python集成开发环境(IDE),而jQuery是一个广泛使用的JavaScript库,用于简化HTML文档遍历、事件处理、动画效果等操作。 虽然PyCharm主要用于Python开发,但它也提供了对JavaScript的支持。在PyCharm中,你可以使用jQuery来开发和调试JavaScript代码。 首先,你需要确保你的PyCharm中已经安装了JavaScript插件。可以通过打开PyCharm的设置(Settings),然后在插件(Plugins)中搜索并安装JavaScript插件。 一旦安装完JavaScript插件,你就可以在PyCharm中创建JavaScript文件,并开始编写jQuery代码了。PyCharm会提供语法高亮、代码补全、错误检查等功能,帮助你更高效地开发JavaScript代码。 另外,如果你想在PyCharm中使用jQuery库,你可以通过以下几种方式引入: 1. 在HTML文件中使用CDN链接:可以通过在HTML文件中添加类似于下面的代码来引入jQuery库: ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> ``` 2. 下载jQuery库文件并本地引入:你可以下载jQuery库的压缩版本(通常是.min.js文件),然后将其保存到项目目录中,并在HTML文件中使用相对路径引入: ```html <script src="path/to/jquery.min.js"></script> ``` 一旦引入了jQuery库,你就可以在JavaScript代码中使用jQuery提供的各种功能了。 希望这个回答对你有帮助!如果你还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值