IE8 iframe没有成功运行JS / CSS代码

时间:2011-01-26 12:25:21

标签: javascript jquery internet-explorer iframe slickgrid

我目前正在将一个日历应用程序混合在一起,我通过iframe将其嵌入到网站中,但我在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="stylesheet" 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);
             });



    }

肮脏我知道,这可以很好地加载自己和FF / Chrome中的iframe,但在IE中最终调用

grid = new Slick.Grid($("#myGrid"), data, columns, options);

造成问题。当我注释掉CSS文件时会发生同样的事情,所以我假设它是一个后加载CSS错误。什么会阻止iframe中的CSS改变?

1 个答案:

答案 0 :(得分:3)

您检查了DOCTYPE吗?某些DOCTYPE在FF / Chrome中触发标准模式,但在IE8中触发Quirks模式。 SlickGrid在Quirks模式下不起作用(不足为奇!)。我刚刚修改了一个非常类似的问题:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

到此:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

See this article for more info.