犀牛中的 jquery

发布于 2024-10-18 22:53:55 字数 779 浏览 9 评论 0原文

我正在尝试将 jquery 加载到 Rhino 中,如链接 here 所示。但我不断收到以下错误:

line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null

我认为 jQuery 完全无法加载 - 但我不知道为什么。我使用的是作者在源代码管理中发布的相同的index.html 文件。

这是我的 Rhino 控制台的跟踪:

js> load( "/temp/env.js" );
js> window.location = '/temp/index.html';
/temp/index.html
js> load( "/temp/jquery.js" );
js: "/temp/jquery.js", line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null
    at /temp/jquery.js:1086
    at /temp/jquery.js:1079
    at /temp/jquery.js:16
    at <stdin>:41

有什么想法吗?

I'm trying to load jquery into Rhino as demonstrated by this link here. But I keep getting the following error:

line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null

I think it's that jQuery is failing to load altogether - but I have no idea why. I'm using the same index.html file that the author posted in source control.

Here is the trace from my Rhino console:

js> load( "/temp/env.js" );
js> window.location = '/temp/index.html';
/temp/index.html
js> load( "/temp/jquery.js" );
js: "/temp/jquery.js", line 1086: uncaught JavaScript runtime exception: TypeError: Cannot call method "importNode" of null
    at /temp/jquery.js:1086
    at /temp/jquery.js:1079
    at /temp/jquery.js:16
    at <stdin>:41

Any ideas?

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

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

发布评论

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

评论(4

满栀 2024-10-25 22:53:55

我使用的是 env.js 文件的版本。事实证明,作者确实使用了它,并将其移至自己的网站等。

新内容是 这里

我一开始使用它,它就对 jQuery 1.5 非常满意。

I was using an OLD version of the env.js file. It turns out the author's really ran with it and moved it over to it's own sites, etc, etc.

The new stuff is here.

As soon as I started using it it was golden with jQuery 1.5.

琉璃梦幻 2024-10-25 22:53:55

我不认为 jQuery(以及许多其他 Web JS 库)可以在 Rhino 中工作,因为 JavaScript 运行时不提供预期的“浏览器全局变量”,如“文档”、“导航器”等。您列出的错误消息表明该库正在尝试读取 Rhino 环境中不存在的某些(可能是浏览器)对象的属性(或调用方法)。

“env.js”项目应该完全执行这种浏览器环境模型,但它似乎是实验性的,可能与您尝试使用的 jQuery 版本不兼容。

I don't think jQuery (and many other web JS libraries) will work in Rhino because that JavaScript runtime doesn't provide the expected "browser globals" like "document", "navigator", etc. The error message you list indicates that the library is trying to read an attribute (or call a method) of some (presumably browser) object that doesn't exist in the Rhino environment.

The "env.js" project should do exactly this sort of browser environment mockup but it appears to be experimental and might not be compatible with the version of jQuery you're trying to use.

以为你会在 2024-10-25 22:53:55

我使用此处的说明成功在 Rhinojs 中运行 jquery

http://geek.michaelgrace.org/2011/09/rhino-and-envjs/

我的步骤:

wget ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip
wget http://www.envjs.com/dist/env.rhino.1.2.js
wget http://code.jquery.com/jquery-1.8.2.js
unzip rhino1_7R2.zip
java -jar rhino1_7R2/js.jar
load("env.rhino.1.2.js");
load("jquery-1.8.2.js");

I succeeded in running jquery in Rhinojs using instructions from here:

http://geek.michaelgrace.org/2011/09/rhino-and-envjs/

My steps:

wget ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip
wget http://www.envjs.com/dist/env.rhino.1.2.js
wget http://code.jquery.com/jquery-1.8.2.js
unzip rhino1_7R2.zip
java -jar rhino1_7R2/js.jar
load("env.rhino.1.2.js");
load("jquery-1.8.2.js");
云归处 2024-10-25 22:53:55

我相信 jQuery 在 Rhino 中毫无用处——你既没有 DOM,也没有 Ajax。 JavaScript 5(在 Rhino 1.7R3 中受支持)有许多必需的功能,例如 JSON 全局对象或数组方法,例如 forEach() 或 map()。

I believe jQuery is useless in Rhino - you have neither DOM nor Ajax. JavaScript 5 (supported in Rhino 1.7R3) has many required fearures, like JSON global object or array methods like forEach() or map().

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