<script>
var iframeInit = setInterval("reinitIframe()" , 200);
var i = 0 ;
function reinitIframe(){
if( i > 50){
clearInterval(iframeInit);
console.log(i);
}
var iframe = document.getElementById("iframe");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight,window.screen.width);
console.log(window.screen.width);
iframe.height = height;
iframe.width = window.screen.width;
console.log(iframe.width);
console.log(iframe.height);
}catch(ex){
}
i++;
}
</script>
在PC端是完美的,但在手机上唉
试过 ajax了,主要是请求网页中的资源路径是写相对的。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
最后用@media了。。。还没有试过 window.document.innerWidth..下次有空尝试下
iframe这种重量级标签,不适合在移动设备上使用