document.getElementById("button").onmouseup=function(oEvent) { if (!oEvent) oEvent=window.event; if (oEvent.button==2) { // alert("右键单击"); } }
/**! *samples to simulate the right button down * *@$('.log_panel') is the target whose mousedown event will be simulated *@$('.rect_box') is the parent of test button *@myevent is the event object passed by ourself * **/ $('.log_panel').mousedown(function(event,myevent){
log('log_panel mouse down');
if(!myevent){ myevent = event; }
log('mouse event:'+ myevent.which+' pos='+ myevent.pageX+','+ myevent.pageY); });//create the button $('<button id="test_bt" value="right_click">right_click</button>').appendTo($('.rect_box')) .click(function(event){ //change the mousedown type as right button down event.which = 3;
log('simulate right button down'); //pass this event as params $('.log_panel').trigger('mousedown',[event]); });
if (!oEvent) oEvent=window.event;
if (oEvent.button==2) {
// alert("右键单击");
}
}
*samples to simulate the right button down
*
*@$('.log_panel') is the target whose mousedown event will be simulated
*@$('.rect_box') is the parent of test button
*@myevent is the event object passed by ourself
*
**/
$('.log_panel').mousedown(function(event,myevent){
log('log_panel mouse down');
if(!myevent){
myevent = event;
}
log('mouse event:'+ myevent.which+' pos='+ myevent.pageX+','+ myevent.pageY);
});//create the button
$('<button id="test_bt" value="right_click">right_click</button>').appendTo($('.rect_box'))
.click(function(event){ //change the mousedown type as right button down
event.which = 3;
log('simulate right button down');
//pass this event as params
$('.log_panel').trigger('mousedown',[event]);
});