<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="shortcut icon" href="/favicon.ico">
<script src="jquery-3.2.1.min.js"></script>
<title></title>
<style>
html,
body {
margin: 0;
}
html { overflow-x: hidden; overflow-y: hidden; }
</style>
<script>
//将页面大小设置为容器的实际尺寸
function windowSize() {
//获取屏幕可见区域的实际大小
width = $(window).width();
height = $(window).height();
console.clear()
console.log(width + "|" + height);
//$("body").css({"width":width,"height":height})
$("iframe").css({
"width": width,
"height": height
})
//设置iframe里的网页的body的高宽
var iframeBody = $('iframe').contents().find('body');
// console.log(iframeBody)
iframeBody.css({
"width": width,
"height": height
})
}
//窗体大小发生变化时重置容器的尺寸
$(window).resize(function() {
windowSize();
});
$(function(){
windowSize()
})
</script>
</head>
<body>
<iframe id="iframepage" scrolling="no" onload="windowSize()" frameborder="0" src="http://39.108.105.54:88"></iframe>
</body>
</html>
iframe自适应
最新推荐文章于 2024-09-29 16:33:00 发布