IE8 iframe 无法成功运行 JS/CSS 代码

发布于 2024-10-14 12:15:53 字数 2923 浏览 2 评论 0原文

我目前正在编写一个日历应用程序,我通过 iframe 嵌入到一个网站中,但我在 Internet Explorer Dirty 中遇到了一个错误,

    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 被更改?

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="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);
             });



    }

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小鸟爱天空丶 2024-10-21 12:15:53

您检查过您的 DOCTYPE 吗?某些 DOCTYPE 在 FF/Chrome 中触发标准模式,但在 IE8 中触发怪异模式。 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">

请参阅这篇文章以获取更多信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文