This patch is proposed based on this forum discussion : Sitepoint forum
The problem is happening when scriptaculous is loaded and try to load the other libraries (effects.js, dragdrop.js , etc.) into the head of the document.
When you use a document that has a MIME type set to "application/xhtml+xml" along with the Firefox navigator, the command "document.write" isn't accepted and refer to this error :
Error: uncaught exception:
[Exception... "Object cannot be created in this context"
code: "9"
nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
location: "http://localhost/script/scriptaculous/scriptaculous.js Line: 26"]
The simplest solution I've found was to use a "try" first to insert the "<script.." into the head via DOM then try a document.write
Current insert :
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
},
Proposed insert :
require: function(libraryName) {
try {
script_tag = document.createElement('script');
script_tag.setAttribute('type','text/javascript');
script_tag.setAttribute('src',libraryName);
head = document.getElementsByTagName("head")[0];
head.appendChild(script_tag);
} catch(e) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
}
},
I've tested this method using Firefox 2 and Internet explorer 7 (sorry to not have an old computer to test the previous versions). Couldn't try it with Safari.
Cross-tested with documents declared as "text/html" and "application/xhtml+xml".