Ticket #2933 (closed bug: fixed)
OpenLayers runs HTML5-incompatible script loading code if the UA string doesn't contain "Safari" or "MSIE"
| Reported by: | hsivonen | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 2.11 Release |
| Component: | general | Version: | 2.10 |
| Keywords: | Cc: | nakor | |
| State: | Commit |
Description
OpenLayers has this bit:
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE")
agent.match("Safari")); if(docWrite) { var allScriptTags = new Array(jsfiles.length);
} var host = OpenLayers._getScriptLocation() + "lib/"; for (var i=0, len=jsfiles.length; i<len; i++) {
if (docWrite) {
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
"'></script>";
} else {
var s = document.createElement("script"); s.src = host + jsfiles[i]; var h = document.getElementsByTagName("head").length ?
document.getElementsByTagName("head")[0] : document.body;
h.appendChild(s);
}
} if (docWrite) {
document.write(allScriptTags.join(""));
}
When docWrite is false, the code that is run doesn't work in browsers that implement script loading and execution according to HTML5 ( http://www.w3.org/TR/html5/scripting-1.html#running-a-script). This includes Firefox 4 beta 7.
To make OpenLayers work in browsers that implement script loading and execution according to HTML5 but that don't contain "MSIE" or "Safari" in the UA string, please run the document.write()-based code path in all browsers.
For more information, please see http://hsivonen.iki.fi/script-execution/
Attachments
Change History
Note: See TracTickets for help on using tickets.Download in other formats:

