Francois Beausoleil
2005-Nov-08 20:49 UTC
Scriptaculous insertion fails when XHTML Strict used in FireFox
Hi !
I'm getting an uncaught exception requiring the Scriptaculous
libraries when everything says XHTML 1.0 Strict:
class ApplicationController < ActionController::Base
before_filter :set_content_type
protected
def set_content_type
response.headers['Content-Type'] = 'application/xhtml+xml;
charset=ISO-8859-1'
end
end
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SMS</title>
<%= javascript_include_tag 'prototype', 'scriptaculous'
%>
</head>
<body>
...
</body>
</html>
The exact error message is:
Error : uncaught exception: [Exception... "Object cannot be created in
this context" code: "9" nsresult: "0x80530009
(NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location:
"http://localhost:4021/javascripts/scriptaculous.js Line: 26"]
Using FireFox 1.5 RC1 on WinXP SP2 Pro, Rails 0.14.3.
After I get the error, I check with the DOM inspector, and sure
enough, the extra script tags aren't present in the DOM.
The problem is the require method of Scriptaculous:
var Scriptaculous = {
Version: '1.5_rc3',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript"
src="'+libraryName+'"></script>');
},
// ...
}
Is there a way to determine if the DOM insertion failed, and fall-back
to document.write only in that case ?
Thanks !
--
François Beausoleil
http://blog.teksol.info/
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thomas Fuchs
2005-Nov-09 09:56 UTC
Re: Scriptaculous insertion fails when XHTML Strict used in FireFox
Heya, For now, include the scripts via <%= javascript_include_tag :defaults %> As of Rails 0.14.3, this will not use the script.aculo.us loader, it will just include prototype.js, effects.js, dragdrop.js and controls.js via <script> tags. The way you describe probably won''t work, because Safari doesn''t read in the scripts if inserted via the DOM. There is probably some browser-specific branching necessary. I''d welcome hearing about any additional findings... :) Cheers, Thomas Am 08.11.2005 um 21:49 schrieb Francois Beausoleil:> Hi ! > > I''m getting an uncaught exception requiring the Scriptaculous > libraries when everything says XHTML 1.0 Strict: > > class ApplicationController < ActionController::Base > before_filter :set_content_type > > protected > def set_content_type > response.headers[''Content-Type''] = ''application/xhtml+xml; > charset=ISO-8859-1'' > end > end > > <?xml version="1.0" encoding="ISO-8859-1"?> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <title>SMS</title> > <%= javascript_include_tag ''prototype'', ''scriptaculous'' %> > </head> > <body> > ... > </body> > </html> > > The exact error message is: > Error : uncaught exception: [Exception... "Object cannot be created in > this context" code: "9" nsresult: "0x80530009 > (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location: > "http://localhost:4021/javascripts/scriptaculous.js Line: 26"] > > Using FireFox 1.5 RC1 on WinXP SP2 Pro, Rails 0.14.3. > > After I get the error, I check with the DOM inspector, and sure > enough, the extra script tags aren''t present in the DOM. > > The problem is the require method of Scriptaculous: > var Scriptaculous = { > Version: ''1.5_rc3'', > require: function(libraryName) { > // inserting via DOM fails in Safari 2.0, so brute force approach > document.write(''<script type="text/javascript" > src="''+libraryName+''"></script>''); > }, > // ... > } > > Is there a way to determine if the DOM insertion failed, and fall-back > to document.write only in that case ? > > Thanks ! > -- > François Beausoleil > http://blog.teksol.info/ > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Francois Beausoleil
2005-Nov-09 13:08 UTC
Re: Scriptaculous insertion fails when XHTML Strict used in FireFox
Hi ! 2005/11/9, Thomas Fuchs <t.fuchs@wollzelle.com>:> For now, include the scripts via <%= javascript_include_tag :defaults %>Thanks. François _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs