Uli: HTML mit Javascript-Objekt-Aufruf

Beitrag lesen

Ich generiere HTML mit einem Aufruf eines Javascript-Objekts (hier: "theTable"). Die JavaScript-Konsole meldet aber "theTable is not defined" - warum?
Wenn man in das onMouseover dagegen this.theTable.msgBox('hello') schreibt erhält man "this.theTable has no properties" - dabei geht es ja nicht um Properties, sondern um einen Funktionsaufruf.

Hat jemand eine Idee, wie dieses Verhalten zu erklären ist?

<html>
<head>
 <title>example</title>
</head>
<script language="JavaScript" >
 function myTable() {
  this.writeTable = function _writeTable() {
   var text = "";
   text = "<table border>";
   text += "<tr onMouseover="this.theTable.msgBox('hello') >\n";
   text += "<td>ABC</td>";
   text += "</table>";
   if(document.getElementById)
    document.getElementById("TableSection").innerHTML = text
   else if(document.all)
    document.all.TableSection.innerHTML = text
   else if(document.layers) {
    document.TableSection.document.open();
    document.TableSection.document.write(text);
    document.TableSection.document.close();
    }
  } // writeTable()

this.msgBox = function _msgBox(mystring) {
   alert(mystring);
  } // msgBox()
 } // class myTable
</script>

<body onLoad="
  var theTable    = new myTable();
  theTable.writeTable();
">
the table:
 <div id="TableSection" ></div>
was here
</body>
</html>