There are two main problems
- The MIME type is
text/javascript
, nottext/jscript
- You are defining the method after you try to call it
So:
function MyObject() {
this.MyMethod = function () {
alert('It works');
}
this.MyMethod(); //should now work
}
var test = new MyObject();