Just for fun, using 1.5.2 syntax:

var Prototype.insertScript = function(url,callback) {
  var script = new Element('script', {
    type: 'text/javascript',
    charset: 'utf-8',
    src: url,
    defer: true // does setting the defer attribute like that work, I
wonder ?
  });

  var stateChangedCallback = function() {
    if (script.readyState && script.readyState != 'loaded' &&
script.readyState != 'complete')
    return;
    script.onreadystatechange = script.onload = null;
    if (callback) callback();
    script.remove();
  };
  script.onload = script.onreadystatechange = stateChangedCallback;

  //Opera 9.10 appears to load the script synchronously. execution
  // could hang here a while.
  document.getElementsByTagName('head').item(0).appendChild(script);

  //safari iframe hack.
  // warning, it has one main issue, the request will be issued two
times.
  // should only be used for static files.
  if (Prototype.Browser.WebKit && callback) {
    var iframe = new Element('iframe', {
      style: 'width: 0px; height: 0px',
      src: url
    });
 
document.getElementsByTagName('body').item(0).appendChild(iframe);
    iframe.onload = function() {
      stateChangedCallback();
      iframe.remove();
    }
  }
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to