Not working here in IE 9 or Firefox 12:
SCRIPT5007: Unable to get value of the property 'offsetWidth': object is null or undefined
motiongallery.js, line 166 character 1
That's IE, Firefox points to the same line and says:
Neither browser displays any images, not even the large image.
I think they're being non-compliant with document.createDocumentFragment(). Or you haven't created/hard coded all of the elements required for the markup side of this script. But I'm not sure, so I've left all that as is in the below.
What you have works in Opera. In Chrome, if I open up the console and run fillup(), it works there too. So obviously the images simply haven't loaded/communicated their dimensions to the browser yet.
Virtually no way to test this locally for me. And there's an extra trailing } in the function in your post, I'm not sure if that's from other code that's not shown or left over from the perhaps inadvertently commented out:
Code:
if ( gallery.length ) {
I went with the latter and reinstated it because that's how it is on the live page. My suggestion:
Code:
function galleryRequest(dir,fil,failure) {
"use strict";
var request2 = makeHttpObject();
var Y = document.getElementById("trueContainer"), loadapproved;
while (Y.childNodes.length){ Y.removeChild(Y.firstChild) };
request2.open("GET","./imageGallery2.php?path="+dir+"/"+fil,true);
request2.send(null);
var myHandler = new Event();
myHandler.addHandler(fillup);
request2.onreadystatechange = function(){
if(request2.readyState == 4){
if(request2.status == 200) {
gallery = new Array();
doScripts( request2.responseText); // evals the returned JS into an array gallery of objects
if ( gallery.length ) {
var frag = document.createDocumentFragment(), imgs = gallery.length;
for (var g=0;g<gallery.length;g++){
var a = document.createElement('a');
a.href = gallery[ g].href;
var i = document.createElement('img');
i.onload = i.onerror = function(){
if(!--imgs){
loadapproved = true;
}
};
i.src = gallery[ g].src;
i.alt = gallery[ g].alt;
i.title = gallery[ g].alt; // i.style.width='48px'; /* totally gross hack */
a.appendChild( i);
frag.appendChild( a);
}
Y.appendChild( frag);
}
(function(){
if(loadapproved){
myHandler.execute();
} else {
var f = arguments.callee;
setTimeout(f, 100);
}
})();
} else if (failure) failure(request2.status, request2.statusText)
}
};
}
Note: This is only to resolve the issue with Chrome. As long as I haven't made or copied any serious typos and/or syntax errors, it should take care of it. However, since you didn't ask and don't seem to think there's an issue with IE or Firefox, I haven't addressed that in the above code.
Any questions?
Bookmarks