User d727ff5bc5
22-09-2010 13:04:20
Hi,
I have a parent html page containing an iFrame which will be updated on-the-fly; the iFrame contains a MarvinView table.
The code of the iFrame is the following:
<html>
<head>
<script LANGUAGE="JavaScript1.1" SRC="../ChemAxon/JChem/marvin/marvin.js"></script>
<script language="JavaScript" type="text/javascript">
function Populate_MView() {
x = parent.XMLMols.getElementsByTagName("ENTRIES")[0];
for (var i = 0; i < x.childNodes.length; i++) {
XMLMol = x.childNodes;
for (var j = 0; j < XMLMol.childNodes.length; j++) {
if (XMLMol.childNodes[j].nodeName == "SMILES") {
var smi = XMLMol.childNodes[j].text;
do {
var err = null;
try {
document.MView.SetM(i*5, smi);
}
catch (err) {
alert(err.description);
}
} while (err != null);
}
}
}
document.MView.setSelectedIndex((x.childNodes.length - 1)*5);
}
</script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
mview_name = "MView";
mview_begin("../ChemAxon/JChem/marvin", 900, 200);
mview_param("cols", "5");
mview_param("rows", "1");
mview_param("visibleRows", "2");
mview_param("visibleCols", "5");
mview_end();
Populate_MView();
</script>
</body>
</html>
The parent page contains a XML object with several entries, one smiles per entry.
On Windows XP + Internet Explorer 6 + Java 1.6 + Marvin 5.3.7, everything works fine.
On Windows 7 + Internet Explorer 8 + Java 1.6 + Marvin 5.3.7, the MarvinView Table in the iFrame will be created but the Javascript will generate an error at document.MView.SetM, and the corresponding error description is "Object doesn't support this property or method".
Interestingly, after the alert pops up, the document.MView.SetM commands works perfectly for all subsequent tries, as well as document.MView.selectedIndex. It seems that my Populate_MView function is fired too early, before the MarvinView Table is created/available.
Any hint of how to solve my issue? Is there any function available that I can call within a loop in Javascript to wait for the MarvinView object to be available? I tried to fire my Populate_MView function in the body onLoad event, but the code hangs at the same place.
Thanks for your help!
Best,
Grégori