A Quick Fix for Responsive Bootstrap Menus on Windows Phone

During a bit of site testing, I encountered a rather strange bug when viewing a site that was developed using the incredible Twitter Bootstrap.

The Responsive collapsing navigation menu didn’t appear to work at all and all of the menu items that were present were all jumbled around. It not only looked bad, but it severely hindered the usability of the site at all.

After some research, I came across the following snippet that appeared to resolve the issue. Simply paste this into the <head> section of your application and it should hopefully resolve your Bootstrap issues on Windows Phone devices:

  1. <!-- Bootstrap Fix for Windows Phone -->    
  2. <script type='text/javascript'>    
  3.         (function() {  
  4.             if ("-ms-user-select" in document.documentElement.style && navigator.userAgent.match(/IEMobile/10.0/)){  
  5.                 var msViewportStyle = document.createElement("style");  
  6.                 msViewportStyle.appendChild(document.createTextNode("@-ms-viewport{width:auto!important}"));  
  7.                 document.getElementsByTagName("head")[0].appendChild(msViewportStyle);  
  8.             }  
  9.         })();  
  10. </script>    

 


Similar Articles