1

我正在尝试在 iFrame 中显示大图像。图像在各种按钮点击时动态加载。虽然这很好用,因为图像很大,当它显示在 iFrame 中时,我需要动态调整它的大小。

有没有办法做到这一点?

谢谢你的帮助。

这就是我正在做的事情。

<iframe id="myFrame" style="width:950; height: 600px; border: 0px solid red;" src="myImage1.png"></iframe>

我需要在 myImage.png 上设置一个宽度。

4

2 回答 2

0

像下面这样在 iframe 中加载图像以实现调整图像大小,

function loadImage(index){
  img.src = images[index];
  var content = "<html><body><img src='"+images[index]+"' width='300' height='200'></body></html>";
  iF.contentWindow.document.open('text/html', 'replace');
  iF.contentWindow.document.write(content);
  iF.contentWindow.document.close();
}

检查我尝试使用 iframe 和 img 的工作示例。

于 2012-10-11T13:18:14.067 回答
0

让按钮将 CSS 类应用于图像并使用 CSS 设置图像的尺寸。

于 2012-10-10T21:10:01.223 回答