0

In my program, I write like this:

function handleFuc( event ){
  var a = event.pageX;
  var b = event.pageY;
  var tempdiv = document.createElement("div");
  tempdiv.onmouseout = function(){
    var x = event.pageX;    // 1
    var y = event.pageY;    //
  }
}
var div = document.getElementById( "id" );
div.onmouseover = function(){
  handleFuc( event );
}

Now, in function handleFuc, how could I distinguish the two "event"?

1
  • You might want to rethink the name of your function. People might take it the wrong way. ;-) Commented May 22, 2010 at 8:07

1 Answer 1

1

You could try the following:

 function handleFuc( event , i=0){
  var a = event.pageX;
  var b = event.pageY;
  var tempdiv = document.createElement("div");
  tempdiv.onmouseout = function(){
    var x = event.pageX;    // 1
    var y = event.pageY;    //
  }
 }
 var div = document.getElementById( "id" );
 div.onmouseover = function(){
   handleFuc( event , 1);
 }

So what I did was add another argument to the function, that defaults to 0, and in the second call of the function you set this argument to 1. So if 2nd argument is 0, the 1st event called it, if it is 1, the 2nd one did...

Ladislav

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.