我有这个代码来放大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';无法计算应该是什么而不是???????
发布于 2013-03-02 22:08:19
** 编辑 **这将帮助您更好,只需在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的建议。
https://stackoverflow.com/questions/15178476
复制相似问题