I am trying to call the function MyMethod from within a object but none of the syntax below works.
There must be a really obvious error below but I can’t see it.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/jscript">
function MyObject() {
//how do I get one of these to work??
this.MyMethod; //does not work
this.MyMethod(); //does not work either
MyMethod(); //does not work either
this.MyMethod = function () {
alert('It works');
}
}
var test = new MyObject();
</script>
</head>
<body>
</body>
</html>
There are two main problems
text/javascript, nottext/jscriptSo: