<div id="iframeBox"> <div class="scale-box"> <iframe allow-full-screen="true"></iframe> <img src="fullScreen.png"> </div> </div>
var ifr = document.querySelector("#iframeBox"); var box = ifr.querySelector('.scale-box'); var src = "/screen/?v=" + Math.random() + "#/home/" + (location.searchObj().id || "1") + "/1/"; document.querySelector("iframe").src = src; function a() { var offsetWidth = ifr.offsetWidth, offsetHeight = ifr.offsetHeight; box.style.transform = `scaleX(${offsetWidth / 1920}) scaleY(${offsetHeight / 1080})`; } window.addEventListener('resize', a, false); a(); document.querySelector("img").onclick = fullScreen;
转载请注明:有爱前端 » scale自适应页面