vwphillips
01-03-2013, 03:21 PM
I have problems with an AJAX script with browsers other than IE or FF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<a href="ajax1.txt" class="popimg" type="AJAX" rev="ajaxcls" rel="file ajax1.txt" >Ajax 1</a>
<script type="text/javascript">
/*<![CDATA[*/
var Test={
init:function(o){
var cls=o.CommonClassName,clds=document.getElementsByTagName('A'),ary=[];
for (var z0=0;z0<clds.length;z0++){
if (this.cls(clds[z0],cls)){
a=clds[z0];
h=a.href.substring(a.href.lastIndexOf('/')+1);
i=a.tabIndex||101;
ary.push([a,a.href,null,null,a.rel||a.title,a.rev,i,'AJAX']);
}
}
o={
ary:ary,
ld:1000
}
this.ajaxiframe(o);
},
cls:function (obj,nme){
return new RegExp(' '+nme+' ').test(' '+obj.className+' ')
},
// Optional IFRAME and AJAX Code
ajaxiframe:function(o){
for (var iframe,z0=0,z1=0;z0<o.ary.length;z0++){
if (typeof(o.ary[z0][1])=='string'){
this.ajaxexit(o,o.ary[z0],new Date());
this.ajax(o,o.ary[z0]);
return
}
}
},
ajaxexit:function(o,ary,d){
var oop=this;
if (new Date()-d<o.ld){
o.dly=setTimeout(function(){ oop.ajaxexit(o,ary,d); },200);
}
else {
alert('Ajax File Not Found\n'+ary[1].substring(ary[1].lastIndexOf('/')+1));
ary[1]=false;
this.ajaxiframe(o);
}
},
ajax:function(o,ary){
var oop=this,html=false;
if (window.ActiveXObject){
try {
html=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
html=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
}
}
}
else if (window.XMLHttpRequest){
html=new XMLHttpRequest();
}
else {
return false;
}
html.onreadystatechange=function(){ oop.ajaxpopulate(o,ary,html); }
html.open('GET',ary[1]+'?'+new Date().getTime(),true);
try {
html.send(null);
}
catch (e){
}
},
ajaxpopulate:function(o,ary,html){
if (html.readyState==4&&(html.status==200||window.location.href.indexOf("http")==-1)){
html=html.responseText;
if (o&&html){
clearTimeout(o.dly);
ary[1]=document.createElement('DIV');
ary[1].innerHTML=html;
ary[1].className=ary[0].rev;
this.ajaxiframe(o);
alert(html);
}
}
}
}
Test.init({
CommonClassName:'popimg' //(optional) the common class name of the links defining the elements to view. (string, default = images defined by array)
});
/*]]>*/
</script>
</body>
</html>
ajax1.txt
The script allows elements to be displayed in a Pop Up.<br>
These elements may be:<br>
IMAGEs,<br>
HTML coded DIVs,<br>
IFRAMEs,<br>
AJAX elements<br>
or images defined by an array.<br>
<br>
The Pop Up is displayed in the center of the page<br>
on top of an optional 'mask' covering the rest of the page content.<br>
<br>
Optional animation allow the Pop Up the be animated open and closed<br>
and the slide show images to be faded in.<br>
The Pop Up is defined in the HTML code to provide the maximum flexibility.<br>
<br>
The elements are displayed in a 'frame' DIV<br>
<br>
An optional control DIV allows the display of:<br>
slideshow control elements,<br>
captions,<br>
a pageing indicator<br>
and pagination.<br>
<br>
Optional persistence restores the last Pop Up on page load.
<br>
<br>
any help will be appreciated
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<a href="ajax1.txt" class="popimg" type="AJAX" rev="ajaxcls" rel="file ajax1.txt" >Ajax 1</a>
<script type="text/javascript">
/*<![CDATA[*/
var Test={
init:function(o){
var cls=o.CommonClassName,clds=document.getElementsByTagName('A'),ary=[];
for (var z0=0;z0<clds.length;z0++){
if (this.cls(clds[z0],cls)){
a=clds[z0];
h=a.href.substring(a.href.lastIndexOf('/')+1);
i=a.tabIndex||101;
ary.push([a,a.href,null,null,a.rel||a.title,a.rev,i,'AJAX']);
}
}
o={
ary:ary,
ld:1000
}
this.ajaxiframe(o);
},
cls:function (obj,nme){
return new RegExp(' '+nme+' ').test(' '+obj.className+' ')
},
// Optional IFRAME and AJAX Code
ajaxiframe:function(o){
for (var iframe,z0=0,z1=0;z0<o.ary.length;z0++){
if (typeof(o.ary[z0][1])=='string'){
this.ajaxexit(o,o.ary[z0],new Date());
this.ajax(o,o.ary[z0]);
return
}
}
},
ajaxexit:function(o,ary,d){
var oop=this;
if (new Date()-d<o.ld){
o.dly=setTimeout(function(){ oop.ajaxexit(o,ary,d); },200);
}
else {
alert('Ajax File Not Found\n'+ary[1].substring(ary[1].lastIndexOf('/')+1));
ary[1]=false;
this.ajaxiframe(o);
}
},
ajax:function(o,ary){
var oop=this,html=false;
if (window.ActiveXObject){
try {
html=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
html=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
}
}
}
else if (window.XMLHttpRequest){
html=new XMLHttpRequest();
}
else {
return false;
}
html.onreadystatechange=function(){ oop.ajaxpopulate(o,ary,html); }
html.open('GET',ary[1]+'?'+new Date().getTime(),true);
try {
html.send(null);
}
catch (e){
}
},
ajaxpopulate:function(o,ary,html){
if (html.readyState==4&&(html.status==200||window.location.href.indexOf("http")==-1)){
html=html.responseText;
if (o&&html){
clearTimeout(o.dly);
ary[1]=document.createElement('DIV');
ary[1].innerHTML=html;
ary[1].className=ary[0].rev;
this.ajaxiframe(o);
alert(html);
}
}
}
}
Test.init({
CommonClassName:'popimg' //(optional) the common class name of the links defining the elements to view. (string, default = images defined by array)
});
/*]]>*/
</script>
</body>
</html>
ajax1.txt
The script allows elements to be displayed in a Pop Up.<br>
These elements may be:<br>
IMAGEs,<br>
HTML coded DIVs,<br>
IFRAMEs,<br>
AJAX elements<br>
or images defined by an array.<br>
<br>
The Pop Up is displayed in the center of the page<br>
on top of an optional 'mask' covering the rest of the page content.<br>
<br>
Optional animation allow the Pop Up the be animated open and closed<br>
and the slide show images to be faded in.<br>
The Pop Up is defined in the HTML code to provide the maximum flexibility.<br>
<br>
The elements are displayed in a 'frame' DIV<br>
<br>
An optional control DIV allows the display of:<br>
slideshow control elements,<br>
captions,<br>
a pageing indicator<br>
and pagination.<br>
<br>
Optional persistence restores the last Pop Up on page load.
<br>
<br>
any help will be appreciated