diff --git a/lib/OpenLayers/Control/Navigation.js b/lib/OpenLayers/Control/Navigation.js index c36e7d8155..4ace37b429 100644 --- a/lib/OpenLayers/Control/Navigation.js +++ b/lib/OpenLayers/Control/Navigation.js @@ -129,7 +129,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, { draw: function() { // disable right mouse context menu for support of right click events if (this.handleRightClicks) { - this.map.div.oncontextmenu = function () { return false;}; + this.map.viewPortDiv.oncontextmenu = function () { return false;}; } var clickCallbacks = { diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index c8321b316a..8da4d6c9b9 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -601,6 +601,7 @@ OpenLayers.Map = OpenLayers.Class({ */ render: function(div) { this.div = OpenLayers.Util.getElement(div); + OpenLayers.Element.addClass(this.div, 'olMap'); this.events.attachToElement(this.div); this.viewPortDiv.parentNode.removeChild(this.viewPortDiv); this.div.appendChild(this.viewPortDiv); diff --git a/tests/Map.html b/tests/Map.html index b60b649685..b5273c245e 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -48,6 +48,10 @@ t.ok(map.viewPortDiv.parentNode == map.div, "Map is attached to a temporary div that holds the viewPortDiv."); var mapDiv = document.getElementById("map"); + // clean up the effects of other tests + while(OpenLayers.Element.hasClass(mapDiv, "olMap")) { + OpenLayers.Element.removeClass(mapDiv, "olMap"); + } map.render(mapDiv); // Can also take a string. t.ok(map.div == mapDiv, "Map is now rendered to the 'map' div.")