我最近在IE7中开始调试我的应用程序,并注意到吨的jQuery并且javascript无法正确加载。但是,如果我从我的javascript.js文件中获取特定功能的片段并在页面底部硬编码我正在处理它......它最终会起作用!
我的一个大问题是,我可以采取哪些一步来使我的jQuery和javascript从其各自的外部文件中正确加载?
这是我的.js文件的示例。这只是一个小片段例子,当我从这个文件中删除它并在页面底部硬编码它被调用它时,它工作。另请注意,我的所有代码都可以在IE8,safari,chrome和firefox中完美运行。
//javascript.js
$(document).ready(function() {
$('a[rel*=facebox]').facebox()
$(".close_facebox").live("click", function(){
$.facebox.close();
});
});
我的自定义javascripts都以其适当的重要层次结构进行实例化。首先是jQuery,然后是主库,最后是我的自定义迷你脚本。
更新
这是我脑袋的副本:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html;charset=UTF-8' http-equiv='content-type' />
<title>HQchannel</title>
<meta content='Local, New Jersey, Promotions, Coupons, Deals, Businesses, telephone, North Jersey' name='keywords' />
<meta content='Your local guide to events, promotions, and every local company near you. We are local search made wonderful.' name='description' />
<meta content='6670644BEAA93299A81158F71F517217' name='msvalidate.01' />
<meta content='c89c098960f9f17d' name='y_key' />
<link href="/stylesheets/reset.css?1280427413" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/text.css?1265032682" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/960.css?1265032682" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/main.css?1289324536" media="screen" rel="stylesheet" type="text/css" />
<link href="/dynamic_stylesheets/image_css.css" media="screen" rel="stylesheet" type="text/css" />
<![if !(IE 6)]>
<link href="/stylesheets/not-ie6.css?1270651849" media="screen" rel="stylesheet" type="text/css" />
<![endif]>
<!--[if IE 7]>
<link href="/stylesheets/is-ie7.css?1276194187" media="screen" rel="stylesheet" type="text/css" />
<![endif]-->
<![if !(IE)]>
<link href="/stylesheets/not-ie.css?1278686676" media="screen" rel="stylesheet" type="text/css" />
<![endif]>
<link href="/stylesheets/themes/main-booger/jquery-ui-1.7.2.custom.css?1267136221" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/facebox.css?1289316781" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery-1.3.2.min.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/jquery-ui-1.7.2.custom.min.js?1267136221" type="text/javascript"></script>
<script src="/javascripts/swfobject.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/jquery.dirtyform.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/jquery.Jcrop.min.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/application.js?1289316793" type="text/javascript"></script>
<script src="/javascripts/jquery.updater.js?1268851685" type="text/javascript"></script>
<script src="/javascripts/jquery.periodicalupdater.js?1268851685" type="text/javascript"></script>
<script src="/javascripts/easyTooltip.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/easySlider.js?1267136221" type="text/javascript"></script>
<script src="/javascripts/facebox.js?1289316781" type="text/javascript"></script>
<script type="text/javascript">
</script>
<link href='/images/favicon.ico' rel='shortcut icon' />
<link href="/stylesheets/jquery.Jcrop.css?1265032682" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/themes/redmond/jquery-ui-1.7.2.custom.css?1265032683" media="screen" rel="stylesheet" type="text/css" />
<link href="/panda_uploader/panda-uploader.css?1272561465" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery-ui-1.7.2.custom.min.js?1267136221" type="text/javascript"></script>
<script src="/javascripts/jquery.Jcrop.min.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/swfupload.js?1265032682" type="text/javascript"></script>
<script src="/javascripts/jquery.swfupload.js?1280435993" type="text/javascript"></script>
<script src="/javascripts/manage.js?1289316781" type="text/javascript"></script>
<script src="/javascripts/ckeditor/ckeditor.js?1281027480" type="text/javascript"></script>
<script src="/panda_uploader/jquery.panda-uploader-1.0.1.min.js?1289316781" type="text/javascript"></script>
</head>
答案 0 :(得分:3)
我敢打赌你有一些语法可以扼杀IE7而不是其他浏览器。这一点我几次
var myLookup = {a: "a", b: "b",};
其他浏览器会使用,
而不是IE7。
无论如何,这是我如何缩小范围。这是痛苦的屁股二进制文件搜索方法。首先完全清除你的javascript.js文件。加载页面。有错误吗?可能不是。现在替换一半的javascript.js文件。有错误吗?如果没有,那么你的问题可能在你删除的一半。有错误吗?然后你可能会在你放回的那一半中出现错误。删除一半的一半,看看是否会导致错误,等等。最终你会把它缩小到IE7不喜欢的一个愚蠢的小东西,你将改变1行代码,并且心情很糟糕。
答案 1 :(得分:1)
另外,仅供参考,您不止一次包含一些文件。某些条件IE注释未正确格式化。它们是这样的:
<!--[if IE]> //do stuff <![endif]-->
您在IE6评论中遗漏了--
,但您的IE7评论是正确的。