gpt4 book ai didi

javascript - 如果图像存在于product_image 1到4 boject路径中,如何使用javascript获取长度

转载 作者:行者123 更新时间:2023-11-28 07:12:32 26 4
gpt4 key购买 nike

在网络服务1中就像这样

                  "product_image1":"http://XYZ.co.uk/product_img/big/1_14238411703234.JPG" ,
"product_image2":"http://XYZ.co.uk/product_img/big/2_14238411703234.JPG" ,
"product_image3":"http://XYZ.co.uk/product_img/big/",
"product_image4":"http://XYZ.co.uk/product_img/big/",

在 webservice 2 中就像这样

"product_image1":"http://XYZ.co.uk/product_img/big/1_14303945253625.jpg" ,
"product_image2":"http://XYZ.co.uk/product_img/big/2_14303945253625.jpg" ,
"product_image3":"http://XYZ.co.uk/product_img/big/3_14303945253625.jpg",
"product_image4":"http://XYZ.co.uk/product_img/big/4_14303945253625.png",

我的代码:-

 items+='<img id="slideImgId3" src='+item.product_image1+' class="detailShowBigImg">';


items+='<img src='+item.product_image1+' onclick="changeImage3(\''+item.product_image1+'\');" class="multiImgShow">';
items+='<img src='+item.product_image2+' onclick="changeImage3(\''+item.product_image2+'\');" class="multiImgShow">';
items+='<img src='+item.product_image3+' onclick="changeImage3(\''+item.product_image3+'\');" class="multiImgShow">';

<script type="text/javascript">
function changeImage3(img3)
{
document.getElementById("slideImgId3").src=img3;
}
</script>

你可以看到webservice 1和webservice 2。在webservice 1中,product_image3和product_image4没有图像,而在webservice 2中,所有对象图像都在那里,那么如何解决这个问题并使其动态。

最佳答案

尝试这组代码

var img = document.getElementById('imageid'); 
//or however you get a handle to the IMG
var width = img.clientWidth;
var height = img.clientHeight;

关于javascript - 如果图像存在于product_image 1到4 boject路径中,如何使用javascript获取长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31153566/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com