Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8722 (new defect)

Opened 1 year ago

Last modified 2 months ago

[PATCH] Make Firefox load scriptaculous properly from XSLT template

Reported by: tomrobst Assigned to: thomas@fesch.at
Priority: normal Milestone: 2.x
Component: script.aculo.us Version:
Severity: major Keywords:
Cc:

Description

When displaying an XML in Firefox with a link to an XSLT stylesheet which loads scriptaculous Firefox (at least) will rewrite the document to include just the new <script> tags dynamically generated by scriptaculous.

Using the DOM appendChild methods (see patch) fixes this problem. Left in the old workaround for Safari browsers.

Attachments

scriptaculous-xslt-firefox.diff (0.9 kB) - added by tomrobst on 06/22/07 12:37:23.
scriptaculous.js diff

Change History

06/22/07 12:37:23 changed by tomrobst

  • attachment scriptaculous-xslt-firefox.diff added.

scriptaculous.js diff

06/22/07 12:48:21 changed by Tobie

if (Prototype.Browser.WebKit) {    
  // inserting via DOM fails in Safari 2.0, so brute force approach 
  document.write('<script type="text/javascript" src="'+libraryName+'"></script>'); 
} else {
  document.getElementsByTagName('head')[0].appendChild(new Element('script', {
    src: libraryName,
    type: 'text/javascript
  }));
}

07/11/07 00:26:14 changed by kalvin

Tobie's code doesn't work for me, even when I fix the typo and put in the tick after javascript. I get an "object cannot be created in this context" error.

Tomrobst's code does work, however.

Thanks!

07/11/07 00:29:22 changed by kalvin

Just some keywords to make this patch easier to find for the next person who encounters the same issues as I did in trying to load scriptaculous.js dynamically: dynamically loading javascript prototype scriptaculous lazy loading includes lazyloader problem

07/12/07 21:08:42 changed by msznapka

Maybe the nicest way is:

new Insertion.Bottom($$('head').first(), new Element('script', {src: libraryName, type: 'text/javascript'}));

you should have latest http://prototypejs.org/assets/2007/5/12/prototype-dev-6728.js works fine in IE7,FF2,Opera9.21,Safari3b

11/08/07 01:33:23 changed by jbpros

This problem also occurs when the document content type is "application/xhtml+xml". Firefox does not allow document.write() stream function when working in standard compliance mode as explained in this FAQ: http://www.mozilla.org/docs/web-developer/faq.html#xhtmldiff.

03/31/08 15:07:44 changed by jcross

  • severity changed from normal to major.

This is an old ticket, but the problem still exists in scriptaculous.js?
Anyway, the msznapka's aproach worked great!
Fixes script hanging in Firefox.

Thanks so much! (I wasted a lot of time on this.)

For others that want to fix Scriptaculous + Firefox + xslt, follow these instructions:

  1. open scriptaculous.js
  2. replace line 30 (version 1.8.1):
    document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
    

with this:

new Insertion.Bottom(
  $$('head').first(), new Element('script',
  {
    src: libraryName,
    type: 'text/javascript'
  }));


Tested with Scriptaculous 1.8.1 in:

  • Firefox 2.0.0.13
  • IE 6
  • Safari 3.1


Jonathan Cross