简体   繁体   English

IE7和IE8的Javascript代码加载问题

[英]Javascript code loading issue with IE7 and IE8

The website in question is cpavalet.com 有问题的网站是cpavalet.com

My javascript loads fine on all browsers except ie7 and ie8. 我的JavaScript在ie7和ie8以外的所有浏览器上均能正常加载。 For a few hours now I have been trying to debug the issue to no avail. 几个小时以来,我一直在尝试调试该问题,但均无济于事。

I am using jQuery and modernizr, and using the supersized library for the full-sized background images. 我正在使用jQuery和modernizr,并使用超大库来显示全尺寸背景图片。

The weird thing is, sometimes when I load the page it loads correctly, other times the javascript doesn't work on the page. 奇怪的是,有时当我加载页面时它正确加载,而其他时候javascript在页面上不起作用。 I think it has to do with the order the scripts are loaded. 我认为这与脚本加载的顺序有关。 I am using document.ready for my jquery scripts. 我正在为jQuery脚本使用document.ready。

Can anyone shed some light as to why it's not working correctly in ie7 and ie8? 谁能阐明为什么它在ie7和ie8中无法正常工作? I am currently using ie8 for testing purposes. 我目前正在使用ie8进行测试。

I am using javascript for: image slider on home page, full-size background images, back to top link to slide to the top, and form validation. 我使用javascript进行以下操作:主页上的图像滑块,全尺寸背景图像,回到顶部的链接以滑动到顶部以及表单验证。

Thanks! 谢谢!

Corey 科里

My guess as to why it wasn't loading correctly was partly correct. 我对它为什么不能正确加载的猜测是部分正确的。 I thought that it was because of the order I had my scripts being run on the page. 我认为这是因为我的脚本在页面上运行的顺序。

The answer is that I was using the defer attribute when loading my scripts. 答案是我在加载脚本时使用了defer属性。 When I removed the defer attributes, the scripts started working correctly again. 当我删除defer属性时,脚本再次开始正常工作。

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

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