0
votes

How can I cancel mouse events in JavaScript?

When I left-click on any object I want to cancel the default behavior of the left mouse click. Is it posible in JavaScript?

On google map on left mouse drag map pan to any direction.

google.maps.event.addListener(Layers.map, 'mousemove', function (event) { // what to do heve }

2
please be more specific. what do you mean by 'default behaviour'? please give a concrete code example. - Kaii
Actually @Kaii I think 'default behavior' is specific enough - it's left to the browser to implement what that behavior is (though its all the same), and Javascript disables this with the preventDefault() method, which is what the OP is looking for. - Mattygabe
google.maps.event.addListener(Layers.map, 'mousemove', function (event) { // what to do heve } - Sadaf

2 Answers

1
votes

Try

document.body.addEventListener("click", function(e) { e.preventDefault(); }, true);

whatever "default behavior" is in your case...

0
votes

You can disable the context menu by using the oncontextmenu event handler in the body tag of your page