问题
When using my Windows Touch Device, holding down on an area results in a an expanding box appearing which extends to about two centimetres squared. Letting go will then result in the right click menu appearing.
The problem is that I want to disable the box and the menu from appearing.
I have managed to prevent the context menu from appearing, but I am still left with the box. I believe the box is interfering with other functionality I have on the page.
Any help much appreciated, Thanks
UPDATE
From reading the following (see section context menus):
http://msdn.microsoft.com/en-us/library/ie/jj583807(v=vs.85).aspx
it appears that I am looking to disable the "hold visual" box.
UPDATE
I have tried to intercept the MSGestureHold event in order to override it, but it does not seem be getting picked up:
if (window.PointerEvent) {
// elm.addEventListener("pointerdown", touchstart, false);
elm.addEventListener("MSGestureHold", touchhold, false);
alert('pointerdown');
} else if (window.MSPointerEvent) {
// elm.addEventListener("MSPointerDown", touchstart, false);
alert('MSPointerDown');
} else {
//elm.addEventListener("mousedown", touchstart, false);
alert('mousedown');
}
I know that in ie11, the MS part of the events has been removed (eg pointerdown above), but gesturehold does not get picked up either. In fact, MSGestureHold does not appear to have been in listed in ie11's Pointer Event Updates page...
回答1:
The event you are looking for is "MSHoldVisual"
Try this:
window.addEventListener("MSHoldVisual", function(e) { e.preventDefault(); }, false);
http://msdn.microsoft.com/en-us/library/ie/jj583807(v=vs.85).aspx
来源:https://stackoverflow.com/questions/23886014/disable-hold-box-on-ie11-w8-1-touch-device