function ImageExist(url)
{
var num;
$.ajax({
url:url,
error: function()
{
num = 0;
},
success: function()
{
num = 1;
}
});
return num;
}
function ChangeColor(color, type){
var count = 1;
while(ImageExist("images/"+type+"/"+color+"/"+count+".jpg") != 0){
count++;
}
var str = "";
var cm = new Array(count);
for(var i = 1; i < count; i++){
cm[i] = "<img src=\"images/"+type+"/"+color+"/"+i+".jpg\" onclick=\"ChangeImg('"+type+"','"+color+"','"+i+"')\">";
str = str+cm[i];
}
document.getElementById("prodPhoto").innerHTML = cm[1];
document.getElementById("prodPhotos").innerHTML = str;
}
function ChangeImg(type, color, img){
var light = "<a href=\"images/"+type+"/"+color+"/"+img+".jpg\" rel=\"lightbox[sofa]\" title=\"Comfort M\"/>";
document.getElementById("prodPhoto").innerHTML = light+"<img src=\"images/"+type+"/"+color+"/"+img+".jpg\">"+"</a>";
}
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
(new Image()).src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
此代码应该找出每个名为 product 和 color 的文件夹中有多少图像。然后将它们输出到 html 页面。它在我的笔记本电脑上运行良好,但在大学网络上它会挂起该网站。
这可能与不是管理员有关吗?