JS奇怪 [英] JS strangeness

查看:45
本文介绍了JS奇怪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我不知道这个问题是否已被多次询问和回答,

因为我刚刚加入这个组并且没有尝试搜索

档案。)


我正在构建一个使用jQuery的页面,而且相当于
。当我在Firefox下本地运行时,一切正常,

但是当我在主机网站上运行时,我经常遇到困难

以下类型。我有一个$(document).ready()函数,

引用在其他JS脚本中定义的变量和元素

(内联),或者在HTML中。有时(但并非总是),引用

这些变量或元素中的一个解析为空指针,

中止执行我的$(文档).ready( )功能导致FF

挂在错误的地方。例如,我有一个JS变量

称为''calimg'',它应该是一个包含图像文件的URL

的字符串,如果我看的话在源代码中,就是在包含$

(文档).ready()函数的脚本之前放置的脚本中定义它是如何定义的。但是,Firebug经常报告,当$(document).ready()函数运行时,
变量''calimg''没有定义。造成这种情况的原因是什么,我该怎么办?

(I don''t know if this question has been asked and answered many times,
since I just joined this group and haven''t attempted to search the
archives.)

I have a page under construction which uses jQuery and is fairly
massive. When I run it locally under Firefox, everything works fine,
but when I run it on the host site, I frequently run into difficulties
of the following type. I have a $(document).ready() function that
references variables and elements defined either in other JS scripts
(inline), or in the HTML. Sometimes, but not always, a reference to
one of these variables or elements resolves to a null pointer, which
aborts the execution of my $(document).ready() function and causes FF
to get hung up in the wrong place. For example, I have a JS variable
called ''calimg'', which is supposed to be a string containing the URL
of an image file, and if I look at the source, that is how it is
defined, in a script that is placed before the script containing the $
(document).ready() function. But often, Firebug reports that the
variable ''calimg'' is not defined when the $(document).ready() function
runs. What is causing this, and what can I do about it?

推荐答案

(文件).ready()函数

引用在其他JS脚本中定义的变量和元素

(内联),或HTML中。有时,但并非总是如此,引用

这些变量或元素之一解析为空指针,

中止执行我的
(document).ready() function that
references variables and elements defined either in other JS scripts
(inline), or in the HTML. Sometimes, but not always, a reference to
one of these variables or elements resolves to a null pointer, which
aborts the execution of my


(document).ready()函数并导致FF

挂在错误的地方。例如,我有一个JS变量

称为''calimg'',它应该是一个包含图像文件的URL

的字符串,如果我看的话在源代码中,就是在包含
(document).ready() function and causes FF
to get hung up in the wrong place. For example, I have a JS variable
called ''calimg'', which is supposed to be a string containing the URL
of an image file, and if I look at the source, that is how it is
defined, in a script that is placed before the script containing the




的脚本之前放置的脚本中,定义了它是如何定义的(b
) document).ready()函数。但通常,Firebug报告说

(document).ready() function. But often, Firebug reports that the
variable ''calimg'' is not defined when the


这篇关于JS奇怪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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