简体   繁体   English

jQuery-IE和$(document).ready(function(){});中应有的对象;

[英]jQuery - Object Expected on IE and $(document).ready(function() {});

I have a page ([LINK REMOVED]) that works completely well in FireFox and Chrome, but for some reason I am getting an "Object Expected" error in most, if not all versions of IE. 我有一个页面([LINK REMOVED])在FireFox和Chrome中完全可以正常运行,但是由于某些原因,即使不是所有版本的IE,我也都在大多数情况下收到“期望对象”错误。

The error occurs on the line 错误发生在网上

$(document).ready(function() {
    //^ Error occurs here ^
    ...
}

I am using jQuery Tools , which implements jQuery 1.4.2, as well as some additional stuff. 我正在使用jQuery Tools ,该工具实现了jQuery 1.4.2,以及一些其他功能。

I've done some reading around. 我已经阅读了一些。 I've tried to put the ready function at the end of the code, right before the </body> tag - in addition, I've tried implementing a timer to let IE load before executing, and I can not shake this error. 我试图将ready函数放在代码的末尾,就在</body>标记之前-此外,我试图实现一个计时器,以便在执行之前让IE加载,并且我不能撼动这个错误。

Here's one problem that can cause IE to choke where other browsers may not: 这是一个可能导致IE在其他浏览器无法阻止的地方阻塞的问题:

$('#' + resultDivName).animate({
  height: '300px', // <=== TRAILING COMMA
}, 500, function() {
  // Animation complete.
});  

Then, in your qtip call, you have: 然后,在qtip调用中,您具有:

target: 'popPart_WM300BP'

I believe target takes a jQuery DOM object , not a string. 我相信target需要一个jQuery DOM对象 ,而不是字符串。 DebugBar points to this line as the cause of "object expected". DebugBar指向此行作为“预期对象”的原因。

Finally, it looks like this version of jQuery Tools includes jQuery 1.4.2. 最后,看起来这个版本的jQuery Tools包含jQuery 1.4.2。 Perhaps 1.4.3 or 1.4.4 would be worth a try. 也许1.4.3或1.4.4值得一试。

Could be the url you're using for jquery.tools . 可能是您用于jquery.tools的网址。 It is missing the http: part. 它缺少http:部分。

//cdn.jquerytools.org/1.2.5/jquery.tools.min.js //cdn.jquerytools.org/1.2.5/jquery.tools.min.js

should be 应该

http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js

If you are testing over a HTTPS connection, check if you are choosing view only the content that was delivered securely. 如果要通过HTTPS连接进行测试,请检查是否选择仅查看安全交付的内容。 If you choose YES maybe the scripts will not be loaded. 如果选择是,则可能不会加载脚本。

This is another gem that causes this error in IE 这是导致IE中出现此错误的另一个原因

Math..random();

Those two dots (..) will ruin you. 那两个点(..)会毁了你。

Your $(document).ready and $(function(){..} methods are just fine - in fact when I fired up the Visual Studio debugger and attached to the page, those methods were firing as expected. The problem is that they are trying to call a function named initializePageMain() that doesn't exist for some reason. As to why that function doesn't seem to exist... I am not sure. 您的$(document).ready$(function(){..}方法都很好-实际上,当我启动Visual Studio调试器并将其附加到页面上时,这些方法正在按预期的方式触发。正试图调用一个名为initializePageMain()的函数,由于某种原因该函数不存在,至于该函数为何似乎不存在...我不确定。

I would also try "fixing" the script tag that contains this code (sidenote: why isn't doToolTips defined in your index.js file?) to read like the rest of your script tags (get rid of the language element: 我还将尝试“修复”包含此代码的脚本标签(旁注:为什么在index.js文件中未定义doToolTips?),使其像其余脚本标签一样阅读(摆脱language元素:

<script type="text/javascript"> ... </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM