Strangeplant
08-18-2008, 02:54 PM
Hi everyone,
I have this problem that has surfaced in FF3 and IE7, but did not exist before with FF2 and IE6, but with the new update to FF2, it doesn't work in FF2 properly (see below).
1. First I build an array of possible images.
2. Then I query the server to see if the files exist.
3. Then I eliminate elements of the array for missing images.
The problem seems to be in the browser accesptiing a server reply - I know the reply is sent from sniffing the transactions on the internet. My code is this:
// Correct imagelink array for any missing elements //
for (m=imagetotl-1;m>=3;m--) {
testExists(imagelink[m]);
if(nB) {
imagetotl--;
for (n=m;n<=imagetotl+1;n++) {
imagelink[n]=imagelink[n+1];
}
}
}
function testExists(imagepath) {
req = getreq();
req.onreadystatechange = imagexists;
req.open("HEAD", imagepath, false);
req.send(null);
// alert("tested "+imagepath); (note that if this is uncommented, if works fine)
}
function imagexists() {
if(req.readyState == 4) {
if(req.status == 200)
{
// image exists
nB=false;
}
else
{
// image doesn't exist
nB=true;
}
}
}
function getreq() { // returns false if exists
if(window.ActiveXObject) { // if IE
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
return;
}
}
} else if(window.XMLHttpRequest) { // if Mozilla, Safari, etc.
return new XMLHttpRequest();
}
}
Now, I found a recent webpost at http://www.mail-archive.com/users@cocoon.apache.org/msg42938.html that says the 'HEAD' requests don't work anymore, and to use 'GET'.....well that doesn't seem to work either in my case. That is unless I add the alert (which I don't want to do, but it makes it work for the recent FF2 update and in FF3.)
How do I solve this problem? What is going on?
I have this problem that has surfaced in FF3 and IE7, but did not exist before with FF2 and IE6, but with the new update to FF2, it doesn't work in FF2 properly (see below).
1. First I build an array of possible images.
2. Then I query the server to see if the files exist.
3. Then I eliminate elements of the array for missing images.
The problem seems to be in the browser accesptiing a server reply - I know the reply is sent from sniffing the transactions on the internet. My code is this:
// Correct imagelink array for any missing elements //
for (m=imagetotl-1;m>=3;m--) {
testExists(imagelink[m]);
if(nB) {
imagetotl--;
for (n=m;n<=imagetotl+1;n++) {
imagelink[n]=imagelink[n+1];
}
}
}
function testExists(imagepath) {
req = getreq();
req.onreadystatechange = imagexists;
req.open("HEAD", imagepath, false);
req.send(null);
// alert("tested "+imagepath); (note that if this is uncommented, if works fine)
}
function imagexists() {
if(req.readyState == 4) {
if(req.status == 200)
{
// image exists
nB=false;
}
else
{
// image doesn't exist
nB=true;
}
}
}
function getreq() { // returns false if exists
if(window.ActiveXObject) { // if IE
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
return;
}
}
} else if(window.XMLHttpRequest) { // if Mozilla, Safari, etc.
return new XMLHttpRequest();
}
}
Now, I found a recent webpost at http://www.mail-archive.com/users@cocoon.apache.org/msg42938.html that says the 'HEAD' requests don't work anymore, and to use 'GET'.....well that doesn't seem to work either in my case. That is unless I add the alert (which I don't want to do, but it makes it work for the recent FF2 update and in FF3.)
How do I solve this problem? What is going on?