0

我有这个用于缩放内容的代码iframe

function SetZoom(){
var ZoomValue = 100;

try{
iframeDoc.body.style.zoom=ZoomValue+'%';
}catch(err){}
try{
iframe.body.style.OTransform = 'scale('+(ZoomValue/100)+')';
}catch(err){}

}

现在我需要模仿 iframe 的缩放,例如

iframe.style.width=(??????/ZoomValue)+'px';
iframe.style.height=(??????/ZoomValue)+'px';

不知道应该用什么代替???????

4

1 回答 1

1

**编辑** 这应该对您有更好的帮助,只需initZoom()在 iframe 添加到 DOM 后调用。

var origWidth, origHeight;

// Call this once on page load
function initZoom(){
  // If you know the iframe's size is in pixels
  origWidth = parseFloat(iframe.style.width);
  origHeight = parseFloat(iframe.style.width);
}

// Call every time you change the zoom level
function zoom(size){
  iframe.style.width = (origWidth * size) + 'px';
  iframe.style.height = (origHeight * size) + 'px';
}

感谢您Basic的建议。

于 2013-03-02T22:08:19.310 回答