2012-02-02 60 views
2

我正在使用在IE8中开发和测试的使用JQuery的解决方案。JQuery和IE8,兼容模式和IE7仿真

我有一个用户,在“工具”>“兼容性视图设置”下显示了“在兼容性视图中显示所有网站”。部分JQuery失败。

$(document).ready(function() { 

    // creating named variables to represent the throbber objects to make life easier later. 
    var moSearchThrobber = $("#imgSearchThrobber"); 
    var moFilterThrobber = $("#imgFilterThrobber"); 

    //lets hide the search and filter dialogs. 
    $("div[id*=pnlSearch_Dialog]").hide(); 
    $("div[id*=pnlFilter_Dialog]").hide(); 

    // when I change the value of my drop downs in search and in filter, set the hidden field value. 
    $("select[name=ddlValue]").change(function() { 
     $(this).siblings("input:hidden").val($(this).val()); 
    }); 
    // If the user clicks on the Search link button. 
    $("a[id*=lnkSearch").click(function() { 

     // while we are at it turn on the search throbber 
     moSearchThrobber.css('visibility', 'visible'); 

     // find the search grid and get/each through all the rows. 
     $("table[id*=grdSearch]").find("tr").each(function() { 

的隐藏功能工作...但点击方法不火......

我一直在寻找试图迫使它进入IE8,并通过meta标签关闭兼容模式。 ..但是这对我来说很肮脏。现在还有其他的选择让jquery在IE8的所有3个“版本”中都一样吗?

+0

您是否收到错误消息?当你说它“失败”时,你的意思是什么? – gilly3 2012-02-02 20:05:39

+0

没有错误...它只是没有发生火灾 – Patrick 2012-02-02 20:17:26

+1

填充代码中的空白,这在IE9兼容性视图中工作:http://jsfiddle.net/WyyUe/。请注意,您在'lnkSearch'选择器中缺少一个末端括号('''),但无论是否在兼容性视图中都会打破它,所以我猜测这只是一个错字。你可以发布一个jsfiddle来看你的bug吗? – gilly3 2012-02-02 20:39:13

回答

4

由于我的评论似乎解决了您的问题,我正在适应它的答案。

您在lnkSearch选择器中缺少一个方括号(])。我本来预计会在IE8和IE9中破解,但显然document.querySelectorAll()接受它。但是,IE7使用sizzle,因为它不支持document.querySelectorAll()。似乎嘶嘶声不喜欢畸形的属性选择器。

这是test page with malformed attribute selectors。在IE9,IE8和IE7模式之间切换,注意它在IE9和IE8中工作,但在IE7中失败。

这是test page with corrected attribute selectors。注意它适用于所有版本。

+0

是的...谢谢你它解决了我的问题。 +1的额外信息。 – Patrick 2012-02-03 18:27:41

2

我使用元标记,因为HTML 5 Boilerplate和其他信誉良好的来源。但你说得对,IE是一个肮脏的行业。

编辑:

Microsoft,IE =边缘应该总是给你提供最新的渲染引擎。 intranet pages是一个例外,它需要明确使用IE = 9来避免兼容模式。

+0

好的一个简单的问题...如果有人使用IE9,并且我把这个元标记放在IE9的某种类型的IE8兼容模式中?我只是猜测,IE7甚至不知道它存在,以便工作好吗? – Patrick 2012-02-02 20:18:29

+0

请参阅上面的新编辑。 – 2012-02-02 20:46:23

+0

感谢您的信息+1 – Patrick 2012-02-03 12:51:07