Fix: Bing Maps Mouse Wheel Bug in Firefox 3.5

Currently Firefox 3.5 is not supported by Bing Maps although there are only minor issues. One issue is that if your page is scrollable and you use the mouse wheel to zoom in or out of the map the page will also scroll. This is not very good for the user experience. After some investigation I have put together the following workaround to correct this issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>

      <script type="text/javascript">
         var map = null;
         function GetMap()
         {
            map = new VEMap(‘myMap’);
            map.LoadMap();
            //Detect if browser is Firefox 3.5
            if (navigator.userAgent.indexOf("Firefox/3.5") != -1)
            {
                document.getElementById("myMap").addEventListener(‘DOMMouseScroll’, WindowMouseWheelHandler, false);
            }
        }
        function WindowMouseWheelHandler(e)
        {
            e.stopPropagation();
            e.preventDefault();
            e.cancelBubble = false;
            return false;
        }
      </script>
   </head>
   <body onload="GetMap();" style="font-family:Arial">
      <div id=’myMap’ style="position:relative; width:600px; height:400px;"></div>
      <!– Page filling div to make the page scrollable–>
      <div style="height:10000px"></div>
   </body>
</html>

Advertisements

2 thoughts on “Fix: Bing Maps Mouse Wheel Bug in Firefox 3.5

  1. Your browser detection is horrible – is this issue really only hits Firefox 3.5? What about 3.0 or 3.6? Users of these browsers will not get this fix although quite likely they will also have the same issue.

    • This is an old post. When this code was written this issue only occured in FireFox 3.5 and there was no Firefox 3.6. At the time it didn’t make sense to target any other browser version as this issue only occured in the one and we didn’t know if the issue would occur in the next versions of FireFox and/or Bing Maps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s