views:

83

answers:

2

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

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).

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 shows preview:

// 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
    }
});

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.

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

Edit: 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.

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.

+1  A: 

Have you ensured your DOCTYPE and X-UA-Compatible are correct

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

And add this just after the <head>

<meta http-equiv="X-UA-Compatible" content="IE=8">
Jason Jong
That is one thing I did check, and it wasn't. However, updating it to that doctype didn't fix anything.Adding the compatibility tag stops it working altogether. When you click to show the preview, it wipes the screen blank as though IE has locked up (cursors persist from last type before entering the window).I have also updated the question with some additional information.
Cyntech
+1  A: 

By forces it to reload in compatibility mode do you mean that you get a flyout balloon notification that says something like: "Internet Explorer encountered a problem with this page and has loaded it in compatibility mode"?

If so, that means you've hit a bug in IE. Called a "Hard assert" it means that the layout engine crashed (not an AV or anything exciting, it just got into an unrecoverable state) and thus IE tries to provide the user with some content by using the older layout engine.

If the problem still occurs in IE9, please file a bug at http://connect.microsoft.com/ie

thanks!

EricLaw -MSFT-
@Eric, yes, that's exactly what happens. I'll give IE9 a try and see if it works there.
Cyntech
@Eric, just had IE9 and Windows 7 test this and it renders the content fine. Thank you for your assistance.
Cyntech