DWR util.js 在 Internet Explorer 中无法工作

发布于 2024-08-15 12:32:53 字数 347 浏览 3 评论 0原文

我在我的项目中使用 DWR 已有几个月了。我尝试在我的一个jsp中使用dwr的util.js,但奇怪的是,当我包含util.js(版本2.0.1)时,没有其他javascript在Internet Explorer中工作(在mozilla中工作正常)。

我正在尝试使用 util.js 操作表格,如此处所述,更令人惊讶的是我什至看不到该链接在 Internet Explorer 中运行良好。

有没有人遇到过这个。有什么帮助吗?

谢谢!

I have been using DWR for couple of months in my project. i tried using dwr's util.js in one of my jsp but strangely when i include util.js(version 2.0.1) none other javascript is working in internet explorer(working fine in mozilla) .

i am trying to manipulate tables with util.js as described here and more surprisingly i can't even see the link functioning well in Internet Explorer.

has anyone come across this. any help?

thanks!

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

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

发布评论

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

评论(1

勿忘初心 2024-08-22 12:32:53

您是否也使用 jQuery、Prototype 或其他使用 $ 函数的 JavaScript 语言?

2.x 版本的 DWR Alias dwr.util.byId 为“$”(已弃用,因为它不如 强大/有用) $ 在 jQuery、Prototype 或类似的版本中)。

他们试图变得聪明,并且仅在未预先定义 $ 的情况下才使用别名,但检查逻辑存在缺陷。

我猜想一开始他们是这样做的:

if(!$){
  //... alias it
}

但后来有人意识到,如果没有定义 $ ,这会抛出一个错误,所以它被提交为:

var $;
if(!$){
  //... alias it
}

这在 Firefox 中工作正常,因为这没有声明$ 的值,只是它存在。

但在 Internet Explorer 中,var 语句将 $ 重新定义为(无)...因此,当运行 if() 测试时它不存在...

检查 3.x (RC )代码,他们为了更稳定而放弃了这个测试:

if(window['

在 Firefox 和 Internet Explorer(以及据我所知所有其他浏览器)中工作正常...只需更新 中的 util.js 文件dwr.jar

我还应该注意:包含库的顺序将决定哪个库获得 $ 函数的所有权。

例如,要让 jQuery 拥有它,请执行以下操作:

<script src="jQuery"...></script>
<script src="dwr/util.js"...></script>

要让 DWR 拥有它,请务必为 jQuery

<script src="jQuery"...></script>
<script>jQuery.noConflict();</script>
<script src="dwr/util.js"...></script>

文档设置 noConflict 标志: jQuery.noConflict

] == null){ //... alias it }

在 Firefox 和 Internet Explorer(以及据我所知所有其他浏览器)中工作正常...只需更新 中的 util.js 文件dwr.jar

我还应该注意:包含库的顺序将决定哪个库获得 $ 函数的所有权。

例如,要让 jQuery 拥有它,请执行以下操作:

要让 DWR 拥有它,请务必为 jQuery

文档设置 noConflict 标志: jQuery.noConflict

By any chance are you also using jQuery, Prototype, or another JavaScript language that uses the $ function?

The 2.x versions of DWR Alias dwr.util.byId as "$" (which is deprecated, since it isn't as powerful/helpful as the $ in jQuery, Prototype or similar).

They tried to be clever, and only do the Alias, if $ wasn't pre-defined, but the check logic is flawed.

I presume at first they did this:

if(!$){
  //... alias it
}

but then someone realized that if $ wasn't defined, this would throw an error, so it was commited as:

var $;
if(!$){
  //... alias it
}

which works fine in Firefox as this doesn't declare a value for $, just that it exists.

But in Internet Explorer, the var statement re-defines $ as (nothing)... thus it doesn't exist when the if() test is run...

Checking the 3.x (RC) code, they ditched this test for the more stable:

if(window['

Which works fine in Firefox AND Internet Explorer (& AFAIK all other browsers)... just update the util.js file in your dwr.jar.

I should also note: the order in which you include libraries will determine which one gets ownership of the $ function.

e.g. to let jQuery have it, do:

<script src="jQuery"...></script>
<script src="dwr/util.js"...></script>

to let DWR have it, be sure to set the noConflict flag for jQuery

<script src="jQuery"...></script>
<script>jQuery.noConflict();</script>
<script src="dwr/util.js"...></script>

Docs: jQuery.noConflict

] == null){ //... alias it }

Which works fine in Firefox AND Internet Explorer (& AFAIK all other browsers)... just update the util.js file in your dwr.jar.

I should also note: the order in which you include libraries will determine which one gets ownership of the $ function.

e.g. to let jQuery have it, do:

to let DWR have it, be sure to set the noConflict flag for jQuery

Docs: jQuery.noConflict

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