Howdy All!
I am really stuck with this one - I want to completely create a table
within JavaScript and insert it into the document, with onMouseOut and
onMouseOver handlers in the table rows.
Below is a sample of the code I have created. It all works in Netscape
7.1, but in IE 6 it shows the table but the handlers do not run. I can
prove the handlers are even there (see the commented out alert command
in the code) so why aren't they being called??
Any help on this problem would be most appreciated!
Rob
:)
<html><head><ti tle>Untitled Document</title>
<script type="text/javascript" language="JavaS cript">
function setAttribute (object, attributeName, attributeValue)
{
var attributeNode = document.create Attribute (attributeName) ;
attributeNode.v alue = attributeValue;
object.setAttri buteNode (attributeNode) ;
} // end setAttribute method
function writeTable()
{
var menuTable = document.create Element ("table");
var tableBody = document.create Element ("tbody");
menuTable.appen dChild (tableBody);
menuTable.setAt tribute ("width", "100%");
menuTable.setAt tribute ("border", "0");
menuTable.setAt tribute ("cellPaddin g", "0");
menuTable.setAt tribute ("cellSpacin g", "0");
// Create a table row for each node in menu array.
for (var index = 0; index < 10; index ++)
{
var tableRow = document.create Element ("tr");
setAttribute (tableRow, "onMouseOut ", "alert ('mouse out');");
setAttribute (tableRow, "onMouseOve r", "alert ('mouse over');");
// alert (tableRow.onmou seout);
var tableCell = document.create Element ("td");
var cellText = document.create TextNode ("Test Row");
tableCell.appen dChild (cellText);
tableRow.append Child (tableCell);
tableBody.appen dChild (tableRow);
} // end for
document.getEle mentById ("mainMenuConta iner").appendCh ild
(menuTable);
}
</script></head>
<body onLoad="writeTa ble();">
<div id="mainMenuCon tainer"></div>
</body>
</html>
I am really stuck with this one - I want to completely create a table
within JavaScript and insert it into the document, with onMouseOut and
onMouseOver handlers in the table rows.
Below is a sample of the code I have created. It all works in Netscape
7.1, but in IE 6 it shows the table but the handlers do not run. I can
prove the handlers are even there (see the commented out alert command
in the code) so why aren't they being called??
Any help on this problem would be most appreciated!
Rob
:)
<html><head><ti tle>Untitled Document</title>
<script type="text/javascript" language="JavaS cript">
function setAttribute (object, attributeName, attributeValue)
{
var attributeNode = document.create Attribute (attributeName) ;
attributeNode.v alue = attributeValue;
object.setAttri buteNode (attributeNode) ;
} // end setAttribute method
function writeTable()
{
var menuTable = document.create Element ("table");
var tableBody = document.create Element ("tbody");
menuTable.appen dChild (tableBody);
menuTable.setAt tribute ("width", "100%");
menuTable.setAt tribute ("border", "0");
menuTable.setAt tribute ("cellPaddin g", "0");
menuTable.setAt tribute ("cellSpacin g", "0");
// Create a table row for each node in menu array.
for (var index = 0; index < 10; index ++)
{
var tableRow = document.create Element ("tr");
setAttribute (tableRow, "onMouseOut ", "alert ('mouse out');");
setAttribute (tableRow, "onMouseOve r", "alert ('mouse over');");
// alert (tableRow.onmou seout);
var tableCell = document.create Element ("td");
var cellText = document.create TextNode ("Test Row");
tableCell.appen dChild (cellText);
tableRow.append Child (tableCell);
tableBody.appen dChild (tableRow);
} // end for
document.getEle mentById ("mainMenuConta iner").appendCh ild
(menuTable);
}
</script></head>
<body onLoad="writeTa ble();">
<div id="mainMenuCon tainer"></div>
</body>
</html>
Comment