showLargeImg.zml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <script>
  2. Z.onload(function()
  3. {
  4. var img = document.getElementById("bigimg");
  5. //Z.EL.set(img, "src", "258969-0-endFile")
  6. var windowW = window.screen.width;//获取当前窗口宽度
  7. var windowH = window.screen.height;//获取当前窗口高度
  8. var realWidth = img.width;//获取图片真实宽度
  9. var realHeight = img.height;//获取图片真实高度
  10. var imgWidth, imgHeight;
  11. var scale = 0.8;//缩放尺寸,当图片真实宽度和高度大于窗口宽度和高度时进行缩放
  12. if (realHeight>windowH*scale)
  13. {//判断图片高度
  14. imgHeight = windowH*scale;//如大于窗口高度,图片高度进行缩放
  15. imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
  16. if (imgWidth>windowW*scale)
  17. {//如宽度扔大于窗口宽度
  18. imgWidth = windowW*scale;//再对宽度进行缩放
  19. }
  20. } else if (realWidth>windowW*scale)
  21. {//如图片高度合适,判断图片宽度
  22. imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放
  23. imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
  24. } else
  25. {//如果图片真实高度和宽度都符合要求,高宽不变
  26. imgWidth = realWidth;
  27. imgHeight = realHeight;
  28. }
  29. //img.setAttribute(imgWidth);
  30. });
  31. function closeDialog()
  32. {
  33. parent.Z.Dialog.close();
  34. }
  35. </script>
  36. <div class="z-pointer" style="" onclick="parent.Z.Dialog.close();" >
  37. <div class="z-text-center z-mg-t20 z-mg-b20">
  38. <img class="z-pointer" id="bigimg" style="vertical-align:middle;border:2px solid #fff;width:auto;height:auto" src="${imgpath}" />
  39. </div>
  40. </div>