Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何更改通过iframe插入的html页面的宽度以适应页面宽度?_Asp.net_Css_Html - Fatal编程技术网

Asp.net 如何更改通过iframe插入的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()

我使用iframe将一个html页面用作另一个html页面的标题。源标题宽度不适合屏幕。有什么方法可以让它适合屏幕吗?

试试这段代码

<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>