简体   繁体   中英

Zooming of iframe contents with iframe itself?

I have this code for zooming contents of iframe

function SetZoom(){
var ZoomValue = 100;

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

}

Now I need to imitate zooming of iframe something like

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

Can't figure what should be instead of ??????? ?

** edit ** This should help you a lot better, just call initZoom() after the iframe has been added to the 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';
}

Thanks to Basic for the advice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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