Apply browser detection patch which will allow us to determine browser name
with a single line, which is useful for the places in the code where we care about what browser we're dealing with. git-svn-id: http://svn.openlayers.org/trunk/openlayers@3322 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -9,8 +9,40 @@
|
||||
</style>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
<!--
|
||||
function init(){
|
||||
|
||||
//set title name to include Browser Detection
|
||||
// this is the only way to test the functionality
|
||||
// of the getBrowserName() function
|
||||
//
|
||||
var header = OpenLayers.Util.getElement("browserHeader");
|
||||
header.innerHTML = "(browser: ";
|
||||
var browserCode = OpenLayers.Util.getBrowserName();
|
||||
switch (browserCode) {
|
||||
case "opera":
|
||||
browserName = "Opera";
|
||||
break;
|
||||
case "msie":
|
||||
browserName = "Internet Explorer";
|
||||
break;
|
||||
case "safari":
|
||||
browserName = "Safari";
|
||||
break;
|
||||
case "firefox":
|
||||
browserName = "FireFox";
|
||||
break;
|
||||
case "mozilla":
|
||||
browserName = "Mozilla";
|
||||
break;
|
||||
default:
|
||||
browserName = "detection error"
|
||||
break;
|
||||
}
|
||||
header.innerHTML += browserName + ")";
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
|
||||
var options = {
|
||||
@@ -45,7 +77,11 @@
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<h1>OpenLayers Example</h1>
|
||||
<table><tr><td>
|
||||
<h1>OpenLayers Example</h1>
|
||||
</td><td>
|
||||
<h3 id="browserHeader"></h3>
|
||||
</td></tr></table>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -965,3 +965,41 @@ OpenLayers.Util.removeTail = function(url) {
|
||||
}
|
||||
return head;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @returns A two-character string which specifies which is the current
|
||||
* browser in which we are running.
|
||||
*
|
||||
* Currently-supported browser detection and codes:
|
||||
* * 'opera' -- Opera
|
||||
* * 'msie' -- Internet Explorer
|
||||
* * 'safari' -- Safari
|
||||
* * 'firefox' -- FireFox
|
||||
* * 'mozilla' -- Mozilla
|
||||
*
|
||||
* If we are unable to property identify the browser, we
|
||||
* return an empty string.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
OpenLayers.Util.getBrowserName = function() {
|
||||
var browserName = "";
|
||||
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if ( ua.indexOf( "opera" ) != -1 ) {
|
||||
browserName = "opera";
|
||||
} else if ( ua.indexOf( "msie" ) != -1 ) {
|
||||
browserName = "msie";
|
||||
} else if ( ua.indexOf( "safari" ) != -1 ) {
|
||||
browserName = "safari";
|
||||
} else if ( ua.indexOf( "mozilla" ) != -1 ) {
|
||||
if ( ua.indexOf( "firefox" ) != -1 ) {
|
||||
browserName = "firefox";
|
||||
} else {
|
||||
browserName = "mozilla";
|
||||
}
|
||||
}
|
||||
|
||||
return browserName;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user