图片未加载 - PhoneGap

时间:2013-01-10 15:49:17

标签: javascript jquery html image cordova

我以编程方式将图像添加到我的html中。在Firefox中,图像正常加载。但是在我测试的所有设备上的android中,都不会出现任何图像。它只是在一个盒子里显示他们的alt。

HTML:

<div class="ui-popup-container fade in" id="popupPhoto-popup" tabindex="0">
        <div data-role="popup" id="popupPhoto" data-overlay-theme="a" data-theme="d" data-corners="false" class="ui-popup ui-body-d ui-overlay-shadow" aria-disabled="false" data-disabled="false" data-shadow="true" data-transition="none" data-position-to="origin">
            <!-- insert images here -->
        </div>
    </div>
<div class="ui-screen-hidden ui-popup-screen" id="popupCloseRight-screen"></div>

JS:

//shows images upon clicking part in table
function tableSelect(location){
//remove previous images
$("#popupPhoto").text("");
//if image was added or not
var boolean = false;
//splits part names
var part = $("#table"+location).text().split(" ");
//part[0] always empty
for(var i=1;i<part.length;i++){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    //so 11 works
    if(part[i] == "11"){
        part[i]="OO";
    }
    //runs through every name in imagedir to see if image exists
    for(var j=0;j<imagedir.length;j++){
        //check if single image
        if(part[i] == imagedir[j]){
            $("#popupPhoto").append($("<img>", {src: 'images/gradegeoImages/'+part[i]+'.png', "class": 'popphoto', alt: part[i] }));
            boolean = true;
            break;
        //checks if double image
        }else if(part[i].concat("1") == imagedir[j]){
            $("#popupPhoto").append($("<img>", {src: 'images/gradegeoImages/'+part[i]+'1.png', "class": 'popphoto', alt: part[i].concat("1") }));
            $("#popupPhoto").append($("<img>", {src: 'images/gradegeoImages/'+part[i]+'2.png', "class": 'popphoto', alt: part[i].concat("2") }));
            boolean = true;
            break;
        }
    }
    //if no images, display "No information available"
    if(boolean == false){
        $("#popupPhoto").append($("<div>", {text: 'No information availabe for '+gradegeo+' of '+part[i]}));
    }
}
//show images
$("#popupPhoto").addClass("ui-popup-active");

}

1 个答案:

答案 0 :(得分:1)

我发现当我在图像路径中调用我的图像时,part [i]的值是大写字母,而图像名称是小写的。在我想到这一点后,我感到非常愚蠢......显然,firefox并不关心你的图像是否区分大小写,因为他们在调试过程中正在那里工作。