簡體   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