Reputation: 385
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"?
Upvotes: 0
Views: 2388
Reputation: 7283
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
Upvotes: 1