我正在使用iframe将html页面用作另一个html页面中的标题。源标题宽度不适合屏幕。有什么方法可以让它适合屏幕吗?
答案 0 :(得分:0)
试试此代码
<script type="text/javascript" >
$(document).ready(function(){
window.setInterval(resizeIframeHeader, 2000);
});
var pastHeight = 0;
function resizeIframeHeader() {
var currentHeight = document.body.scrollHeight;
var currentWidth = document.body.scrollWidth;
if (currentHeight != pastHeight){
pastHeight = currentHeight;
parent.postMessage(document.body.scrollHeight, '*');
}
if (currentWidth != pastWidth){
pastHeight = currentWidth ;
parent.postMessage(document.body.scrollWidth, '*');
}
}
</script>
答案 1 :(得分:0)
以下是您网页的小提琴:Fiddle
<body>
Your page content
</body>