IE8 iframe 无法成功运行 JS/CSS 代码
我目前正在编写一个日历应用程序,我通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您检查过您的 DOCTYPE 吗?某些 DOCTYPE 在 FF/Chrome 中触发标准模式,但在 IE8 中触发怪异模式。 SlickGrid 在 Quirks 模式下不起作用(毫不奇怪!)。我刚刚通过将其更改为:
请参阅这篇文章以获取更多信息。
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:
to this:
See this article for more info.