Hello,
I'm having difficulty using attachEvent instead of simply assigning to
mouseover in my object Sample03. When i use myImage.onmouse over =
this.showmouseo ver(); in the following all works fine, if I replace it by
myImage.attachE vent('onmouseov er',this.showmo useover()); I get for the
alert(this.id) "undefined" and not "gwlogo"
<html>
<head>
</head>
<SCRIPT language="javas cript" type="text/javascript">
var Sample03 = function(){
this.Property01 = "Prop01";
var myImage = document.getEle mentById("gwlog o");
myImage.onmouse over = this.showmouseo ver();
//myImage.attachE vent('onmouseov er',this.showmo useover());
}
Sample03.protot ype.showmouseov er = function()
{
var _this = this;
return(
function(e){
alert(this.id);
alert(_this.Pro perty01);
})
}
window.onload=f unction(){
var mySample = new Sample03();
}
</SCRIPT>
<body>
<img src="http://localhost/winxp.gif" id="gwlogo">
</body>
</html>
Thank you for your assistance.
I'm having difficulty using attachEvent instead of simply assigning to
mouseover in my object Sample03. When i use myImage.onmouse over =
this.showmouseo ver(); in the following all works fine, if I replace it by
myImage.attachE vent('onmouseov er',this.showmo useover()); I get for the
alert(this.id) "undefined" and not "gwlogo"
<html>
<head>
</head>
<SCRIPT language="javas cript" type="text/javascript">
var Sample03 = function(){
this.Property01 = "Prop01";
var myImage = document.getEle mentById("gwlog o");
myImage.onmouse over = this.showmouseo ver();
//myImage.attachE vent('onmouseov er',this.showmo useover());
}
Sample03.protot ype.showmouseov er = function()
{
var _this = this;
return(
function(e){
alert(this.id);
alert(_this.Pro perty01);
})
}
window.onload=f unction(){
var mySample = new Sample03();
}
</SCRIPT>
<body>
<img src="http://localhost/winxp.gif" id="gwlogo">
</body>
</html>
Thank you for your assistance.
Comment