Topic: When did you start with Ajax? (Page 1 of 1) |
|
|---|---|
|
Bipolar (III) Inmate From: Umeå, Sweden |
posted 12-21-2006 14:07
Just found this snippet stored away on one of my harddrives. Dated March 2003: code: /***********************\
* Dynamic File Reader *
* by: Liorean *
\***********************/
function File(){
var r;
switch(0+(1*(typeof document.getElementById!='undefined')+2*(typeof clientInformation!='undefined')+4*(typeof netscape!='undefined'))*(typeof opera=='undefined')){
case 3:
r=new ActiveXObject('Microsoft.XMLHTTP');
break;
case 4:
r=new NN4HttpRequest;
break;
case 5:
r=new XMLHttpRequest;
break;
default:
r={
open:function(){},
send:function(){return false},
responseText:''
};
break
}
this.prototype=r;
return r;
}
function NN4HttpRequest(){
this.url=this.responseText=''
}
NN4HttpRequest.prototype.open=function(m,u){
this.method=m||'GET';
this.url=u
}
NN4HttpRequest.prototype.send=function(){
if(this.url=='')return false;
if(!/^[a-z]+:/.test(this.url))
this.url=String(window.location).replace(/\/[^\/]*$/,'/'+this.url);
var l,
b;
this.responseText='';
b=new java.io.BufferedReader(new java.io.InputStreamReader(new java.net.URL(this.url).openStream()));
while((l=b.readLine())!=null)
this.responseText+=l+'\n';
if(b!=null)
b.close();
return true
}Seems you can teach old dogs new tricks after all |
|
Paranoid (IV) Inmate From: Norway |
posted 12-21-2006 17:04
|
|
Bipolar (III) Inmate From: Umeå, Sweden |
posted 12-21-2006 21:04
Well, I did some form of JavaScript Remote Scripting Back in nn4/ie4, but you had to jump through hoops and climb over cesspits to get it working there... and half the time the browser crashed if your file timed out... |
|
Paranoid (IV) Inmate From: Australia |
posted 01-03-2007 02:50
2006 |