Asp.net 如何更改通过iframe插入的html页面的宽度以适应页面宽度?
我使用iframe将一个html页面用作另一个html页面的标题。源标题宽度不适合屏幕。有什么方法可以让它适合屏幕吗?试试这段代码Asp.net 如何更改通过iframe插入的html页面的宽度以适应页面宽度?,asp.net,css,html,Asp.net,Css,Html,我使用iframe将一个html页面用作另一个html页面的标题。源标题宽度不适合屏幕。有什么方法可以让它适合屏幕吗?试试这段代码 <script type="text/javascript" > $(document).ready(function(){ window.setInterval(resizeIframeHeader, 2000); }); var pastHeight = 0; function resizeIframeHeader()
<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>
$(文档).ready(函数(){
setInterval(resizeIframeHeader,2000);
});
var pastHeight=0;
函数resizeIframeHeader(){
var currentHeight=document.body.scrollHeight;
var currentWidth=document.body.scrollWidth;
如果(当前高度!=过去高度){
pastHeight=当前高度;
parent.postMessage(document.body.scrollHeight,'*');
}
如果(currentWidth!=pastWidth){
pastHeight=当前宽度;
parent.postMessage(document.body.scrollWidth,'*');
}
}
这是一把小提琴,可以放在你的页面上:
您的页面内容
为什么要为此使用iframe?来源是什么?其他网站?是的,其他网页不在同一服务器上。您有权访问其他服务器吗?否,我使用url访问该网页,如“”
<body>
Your page content
</body>