English 中文(简体)
Using table inside dijit.form.ContentPane doesn t work in Internet Explorer 7
原标题:

I m having problems using a table inside a ContentPane. It seems to work fine in Firefox but is invisible in Internet Explorer 7. The html below demonstrates what I mean. In Firefox you get:

Before Table
This is the table
After Table

In Internet Explorer 7 you get:

Before Table
After Table

No table at all. Does anyone know the cause of this problem?

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dojo/resources/dojo.css" />
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dijit/themes/tundra/tundra.css" />
<script djConfig="parseOnLoad:true" type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js">
</script>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.form.Form");
dojo.addOnLoad(initialize);
function initialize() {
    var contentPane = new dijit.layout.ContentPane({});
 contentPane.domNode.appendChild(document.createTextNode("Before Table"));
 var table = document.createElement("table");
 var tr = document.createElement("tr");
 var td = document.createElement("td");
 td.appendChild(document.createTextNode("This is the table"));
 tr.appendChild(td);
 table.appendChild(tr);
 contentPane.domNode.appendChild(table);
 contentPane.domNode.appendChild(document.createTextNode("After Table"));
 dojo.place(contentPane.domNode, dojo.body(), "first");
}
</script>
</head>
<body class="tundra"></body>
</html>
问题回答

I found the problem. When creating a table programmatically, you need to make sure you place a tbody node inside the table node (and the tr nodes within that). The following works:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dojo/resources/dojo.css" />
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dijit/themes/tundra/tundra.css" />
<script djConfig="parseOnLoad:true" type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js">
</script>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.addOnLoad(initialize);
function initialize() {
    var contentPane = new dijit.layout.ContentPane({});
    contentPane.domNode.appendChild(document.createTextNode("Before Table"));
    var table = document.createElement("table");
    var tbody = document.createElement("tbody");
    var tr = document.createElement("tr");
    var td = document.createElement("td");
    td.appendChild(document.createTextNode("This is the table"));
    tr.appendChild(td);
    tbody.appendChild(tr);
    table.appendChild(tbody);
    contentPane.domNode.appendChild(table);
    contentPane.domNode.appendChild(document.createTextNode("After Table"));
    dojo.place(contentPane.domNode, dojo.body(), "first");
}
</script>
</head>
<body class="tundra"></body>
</html>




相关问题
jquery set div width fails in IE7

I have the following code and it works correctly in FF and IE8 but fails in IE 7 anyone have an idea or hack if ($("#midRight:contains( Quick Links )").length == 0) { $("#midCenter").css({ ...

Ie7 float right bug?

I have a div floated right. Inside that div are two other divs. The first div has a background color and when I refresh, it s "bleeding" into the second div. (Sometimes in front of it sometimes ...

IE errors with jQuery & timeout

In a jquery hover event I use the following code to drop down a menu: clearTimeout(hTimeout); $( #lowermenu ).queue( fx , []); $( #menucenter .current ).removeClass( current ); $(this).children( a )....

window.onbeforeunload not firing in child window

I want to bind a function to the beforeunload event of a child window in Javascript. I have the following code: newWind = window.open(settings.url, "Dialog", "width=" + settings.width + ",height=" + ...

My App s email shows up blank in IE7

My app sends out email to users (upon signup, welcome etc.) and they show up blank in IE. Fine in IE8, Firefox. The content-type for the email is set to html. The email has links. Any pointers on how ...

热门标签