将数据插入div时,IE8强制执行兼容模式 [英] IE8 forces compatibility mode when inserting data into a div

查看:181
本文介绍了将数据插入div时,IE8强制执行兼容模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一整天都在与IE8的兼容模式作斗争,而且我正准备好了。

I've been fighting against IE8's compatibility mode all day and I'm about to chuck a brick at it.

我有一些代码,它使用了jquery 1.2 (是的,它是旧的 - 不能改变它),在我们的网络应用程序中搜索一些记录。可以单击搜索结果以查看记录的内容(通过使用.animate(),它会在行下面打开一个空格,并在下面创建另一个TR并从json feed中插入HTML数据)。

I have some code, which uses jquery 1.2 (yes it's old - can't change that), to search for some records in our web app. The results of the search can be clicked on to view the contents of the record (by using .animate() it opens a space under the row and creates another TR underneath and inserts HTML data from a json feed).

在IE8中,单击结果以查看内容会强制它在兼容模式下重新加载,在所有其他浏览器(IE7,FF3.0 +,Chrome,Safari)中它可以正常工作。我一直在尝试使用IE8的开发人员工具栏来调试和追踪为什么会发生这种情况,但我无法找到任何错误或任何可能导致错误的证据。

In IE8, clicking on a result to view the content forces it to reload in compatibility mode, where it works fine in all other browsers (IE7, FF3.0+, Chrome, Safari). I've been trying to use IE8's developer toolbar to debug and track down why this is happening but I've not been able to find any error or any evidence of what might be causing it.

显示预览的代码:

// Code that binds a click to open the result preview:
var _tr = $('<tr class="outline" id=' + val.assessment.assessmentId + '></tr>').bind("click", msi.reuseAssessment.preview);

...

// in msi.reuseAssessment.preview()
var url = "/direct/msi-assessment/" + assessmentId + "/assessmentHtml.json?no-cache=true";
jQuery.ajax({
    type: "GET",
    url: url,
    dataType: "json",
    success: function(d, textStatus){
        var _content = d.assessmentHtml;
        var _preview = $("<tr id=" + assessmentId + "></tr>");

        // loadContent 
        _tr.after(_preview.animate({
            height: 50
        }, 500, 0, function() {
            msi.reuseAssessment.drawPreview(this, _content); // Puts the content from the json into a td
        }));
    },
    error: function(xmlHttpReq, status, errorThrown) {
        // display error msg
    }
});

使用IE8的开发人员工具逐步完成代码,它会在这里传递到某个地方,进入jQuery的代码,这就是在兼容模式下刷新时。我已经验证了JSON,w3c提供的HTML代码,一切都很好,我真的不知道发生了什么。

Stepping through the code using IE8's developer tools, it gets passed here and into somewhere into jQuery's code and that's when it refreshes in compatibility mode. I've validated the JSON, the HTML code that comes out with w3c and it's all fine, I'm really at a loss as to what's happening.

有谁知道我怎样才能更好地追踪导致它的原因,或者我应该在这些页面上强制使用IE7模式?

Does anyone know how I might better track down what's causing it, or should I just force IE7 mode on these pages?

编辑:搜索是在出现的ajax'popup'中执行的在屏幕的顶部。它的模板(基本HTML)从单独的HTML文件加载,并注入原始页面底部的div。这意味着会有嵌套的HTML文件(< html>< / html> 标签等)。这会影响它吗?

编辑3:删除这些重复的标签并没有解决问题。

The search is performed in an ajax 'popup' that appears over the top of the screen. It's template (base HTML) is loaded from a separate HTML file, and injected into a div at the bottom of the original page. This means there would be nested HTML files (with <html></html> tags etc). Would this affect it also?
Edit 3: removing these duplicate tags did not fix the problem.

编辑2:仍然没有解决这个。它只是其中一个IE8无法正常显示并将其归结为浏览器的怪癖吗?我真的很感激一些帮助。

Edit 2: Still haven't solved this. Is it just one of those things that IE8 won't display properly and put it down to browser quirk? I would really appreciate some help on this.

推荐答案

在同事做了一些搜索后,我们发现这个在SO上,已确认max-height在IE8中导致硬断言,确认事实上,正如EricLaw发布的那样,IE8中存在一个错误。

After a colleague did some searching as well, we found this here on SO, where it's been confirmed that max-height is causing a hard assert in IE8, confirming that it is, indeed, a bug in IE8 as EricLaw posted.

我们使用max-height作为我们插入内容的div的样式,反过来导致硬断言。以上链接的问题可以解决其他遇到此问题的问题。

We were using max-height for the style of the div we were inserting the content into, and in turn, causing the hard assert. The above linked question has a work around for anyone else encountering this problem.

这篇关于将数据插入div时,IE8强制执行兼容模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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