未捕获的ReferenceError:初始化PDF.JS时未定义PDFJS [英] Uncaught ReferenceError: PDFJS is not defined when initialising PDF.JS

查看:1720
本文介绍了未捕获的ReferenceError:初始化PDF.JS时未定义PDFJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在某种CMS中安装PDF.JS,在该CMS中,页面的外部骨架是为我构建的,包括对jQuery(仍为1.10.2版)的引用.

I am trying to install PDF.JS in a CMS of sorts where the outer skeleton of the page is built for me, including the reference to jQuery (which is still version 1.10.2).

我尝试添加以下两行:

<script src="https://mozilla.github.io/pdf.js/build/pdf.js"></script>
<script src="https://mozilla.github.io/pdf.js/build/pdf.worker.js"></script>

运行此命令:

<script>
    PDFJS.getDocument('/loc/testpdf.pdf');
</script>

但是他们返回此错误:

VM485:14 Uncaught ReferenceError: PDFJS is not defined
at eval (eval at <anonymous> (jquery.js?v=910.1:4), <anonymous>:14:1)
at eval (<anonymous>)
at jquery.js?v=910.1:4
at Function.globalEval (jquery.js?v=910.1:4)
at init.domManip (jquery.js?v=910.1:5)
at init.append (jquery.js?v=910.1:5)
at init.<anonymous> (jquery.js?v=910.1:5)
at Function.access (jquery.js?v=910.1:4)
at init.html (jquery.js?v=910.1:5)

我已经走了两个小时,试图找出问题所在.我是否正确初始化了它,或者我们认为它与jQuery的过时版本有关?

I have been going round for a couple of hours trying to figure out what's wrong. Have I initialised it correctly or do we think it's related to the outdated version of jQuery?

谢谢

推荐答案

在页面加载后尝试运行脚本;

try run the script after page loaded;

$(document).ready(function () {
    PDFJS.getDocument('/loc/testpdf.pdf');
})

这篇关于未捕获的ReferenceError:初始化PDF.JS时未定义PDFJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆