a while back, I was working on FCKeditor for Konqueror, and lamented that <script> .onloads didn't work.
today, I was debugging some scripts for Safari, and came up with a function that can be used to supply that functionality. here's a loading script for Safari/Konqueror which can be easily adapted to provide an onload trigger.
function loadExternalScript(url){
for(i in loadedScripts)if(loadedScripts[i]==url)return 0;
loadedScripts.push(url);
if(sajax_is_loaded&&/\.php/.test(url))url+=(/\?/.test(url)?'&':'?')+'sajax_is_loaded';
var x=new XMLHttpRequest();
x.open('GET',url,true);
x.onreadystatechange=function(){
if(x.readyState!=4)return;
var t=x.responseText.replace(/\\/g,'\\\\').replace(/"/g,'\\"').replace(/\n/g,"\\n");
setTimeout('eval("'+t+'");',0);
}
x.send(null);
return 1;
}
I'll be working on getting FCKeditor to work in Safari in a while (I have just had a MacOSX machine placed on my desk in preparation of this). Hopefully we can get this done!
Kae
Sun, 04/02/2006 - 08:19
#1
RE: onload for troublesome browsers
I took the boss's old laptop home over the weekend as it had Mac OSX on it. Unfortunately, the version of Safari was 1.0.3, which doesn't have an XMLHttpRequest object, doesn't load external scripts attached to the head, and even more distressingly, doesn't allow a page to read or write to its contained IFrames!
So - I couldn't make any progress at all in Safari (apart from figuring out those facts).
But, I /did/ make some progress in Konqueror. The method I described in my previous post (how to load dynamic code without adding script elements to the head) worked beautifully. You can see that function in action by going to the demo page in Konqueror:
http://verens.com/demos/fckeditor4safar ... ource=true
The code is attached to this file:
http://verens.com/demos/fckeditor4safar ... tloader.js
Note the little utf8 ripper-outer - I found that Konqueror cannot handle the characters \u2200 and \u2203 (mathematical symbols for "for all" and "exists").
Haven't managed to check this in Safari, but I suspect it will have the same bug.