Prevent the default browser behavior without stopping the event propagation.

This commit is contained in:
Frederic Junod
2012-03-14 10:30:03 +01:00
parent cf92ced1c8
commit a6119f6a75
4 changed files with 29 additions and 22 deletions

View File

@@ -167,11 +167,7 @@ OpenLayers.Event = {
stop: function(event, allowDefault) {
if (!allowDefault) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
OpenLayers.Event.preventDefault(event);
}
if (event.stopPropagation) {
@@ -181,6 +177,22 @@ OpenLayers.Event = {
}
},
/**
* Method: preventDefault
* Cancels the event if it is cancelable, without stopping further
* propagation of the event.
*
* Parameters:
* event - {Event}
*/
preventDefault: function(event) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
},
/**
* Method: findElement
*