繁体   English   中英

使用iframe本身缩放iframe内容?

[英]Zooming of iframe contents with iframe itself?

我有这段代码用于缩放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';

无法确定应该代替什么???????

** 编辑 **这应该可以为您提供更好的帮助,只需将iframe添加到DOM后再调用initZoom()

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提供的建议。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM