469,315 Members | 1,542 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

Mozilla Event problem

for mozilla event to be captured we write
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function temp(event)
  3.  {
  4.      alert(event.clientX);
  5.  }
  6. </script>
  7. <div onmouseover="temp(event)">
  8.  
Now in case of objects,how do i capture events for mozilla
The problem is as follows
Expand|Select|Wrap|Line Numbers
  1. function temp()
  2.  {
  3.     this.div=document.createElement('div');
  4.     this.div.id="abc";
  5.     this.div.onmousehover=function(){this.abc(event)}/*<------Here event is undefined 
  6.                                                                            so function is not called for  
  7.                                                                            mozilla*/
  8.    this.div.onclick=this.abc//<-----Here object reference is lost
  9.  }
  10. temp.prototype.abc=function(eve)
  11.  {
  12.     alert(eve.clientX);
  13.  }
  14.  
Oct 6 '07 #1
3 1137
gits
5,390 Expert Mod 4TB
hi ...

try this:

Expand|Select|Wrap|Line Numbers
  1. // you need this to fix the scope
  2. // for the anonymous function you 
  3. // will use
  4. var me = this;
  5.  
  6. this.div.onmouseover = function(e) { me.abc(e) };
kind regards
Oct 7 '07 #2
hi ...

try this:

Expand|Select|Wrap|Line Numbers
  1. // you need this to fix the scope
  2. // for the anonymous function you 
  3. // will use
  4. var me = this;
  5.  
  6. this.div.onmouseover = function(e) { me.abc(e) };
kind regards
thnx it worked................... :D
Oct 7 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that you got it working :) ... post back to the forum anytime you have more questions ...

kind regards
Oct 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by tony kulik | last post: by
3 posts views Thread by | last post: by
1 post views Thread by Greg | last post: by
6 posts views Thread by Erik Steffl | last post: by
15 posts views Thread by prabhdeep | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.