IE8 iframe not successfully running JS/CSS code
I am currently hacking together a calendar application which I am embedding into a website via an iframe, but I have come across a bug in internet explorer
function BuildListView(startday, l, events, config){
var cc = '<div id="myGrid" style="width:95%;height:95%;"></div>';
var html = [];
html.push(cc);
html.push('<link rel="styl开发者_运维问答esheet" href="../slickgrid/slick.grid.css" type="text/css" media="screen" charset="utf-8" /> ');
html.push('<link rel="stylesheet" href="../slickgrid/css/smoothness/jquery-ui-1.8.2.custom.css" type="text/css" media="screen" charset="utf-8" /> ');
html.push('<link rel="stylesheet" href="../slickgrid/examples/examples.css" type="text/css" media="screen" charset="utf-8" /> ');
html.push('<script language="JavaScript" src="../slickgrid/lib/jquery.event.drag-2.0.min.js"></script>');
html.push('<script language="JavaScript" src="../slickgrid/slick.grid.js"></script>');
gridcontainer.html(html.join(""));
html = null;
var grid;
var columns = [
{id:"event", name:"Event", field:"event",width:300},
{id:"start", name:"Start", field:"start",width:175},
{id:"finish", name:"Finish", field:"finish",width:175},
{id:"location", name:"Location", field:"location",width:200}
];
function sortByStart(a, b) {
var x = a.start.toLowerCase();
var y = b.start.toLowerCase();
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
var options = {
enableCellNavigation: false,
enableColumnReorder: false,
rowCssClasses: function(item) {
// if a task is 100% done then its row gets an additional CSS class
return (item.event == "Task 0") ? 'complete' : '';
}
};
$.getJSON("../cal.php", function(json) {
var data = [];
var i=0;
$.each(json.events, function(index, event) {
data[i++] = {
event: event[1],
start: event[2],
finish: event[3],
location: event[9],
};
});
data.sort(sortByStart);
$.each(data,function(index, value){
value.start = (new Date(value.start)).toUTCString();
value.finish = (new Date(value.finish)).toUTCString();
})
grid = new Slick.Grid($("#myGrid"), data, columns, options);
});
}
Dirty I know, this works fine loaded by itself and in iframes in FF/Chrome but in IE the final call
grid = new Slick.Grid($("#myGrid"), data, columns, options);
Is causing problems. The same thing happens when I comment out the CSS files so I'm assuming it's a post load CSS error. What would stop the CSS in an iframe being altered?
Have you checked your DOCTYPE? Some DOCTYPEs trigger Standards mode in FF/Chrome but Quirks mode in IE8. SlickGrid doesn't work in Quirks mode (not surprisingly!). I just fixed a very similar problem by changing this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
to this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
See this article for more info.
精彩评论