admin管理员组文章数量:1025533
Is it possible to adjust the height of the iframe scroll according to the size of the screen (browser)? It would be like simply replacing the default browser scroll with the iframe scroll. Here is what I mean by this:
I currently have my browser scroll disabled:
<style type="text/css">
html, body {
overflow: hidden;
}
</style>
I have my iframe:
<iframe width="100%" src="" scrolling="yes" frameborder="0" height="100%">
</iframe>
With width set to 100% the iframe scroll bar is pushed to the far right somewhat replacing the default browser scroll bar and my iframe is now the center piece of the website, (yahoo is an example). I can always adjust the height of the iframe to fit my specific browser size however is there a way I set the iframe scroll according to the browser height automatically? Make it responsive to the browser height just like it is to the width?
Is it possible to adjust the height of the iframe scroll according to the size of the screen (browser)? It would be like simply replacing the default browser scroll with the iframe scroll. Here is what I mean by this:
I currently have my browser scroll disabled:
<style type="text/css">
html, body {
overflow: hidden;
}
</style>
I have my iframe:
<iframe width="100%" src="http://www.yahoo." scrolling="yes" frameborder="0" height="100%">
</iframe>
With width set to 100% the iframe scroll bar is pushed to the far right somewhat replacing the default browser scroll bar and my iframe is now the center piece of the website, (yahoo is an example). I can always adjust the height of the iframe to fit my specific browser size however is there a way I set the iframe scroll according to the browser height automatically? Make it responsive to the browser height just like it is to the width?
Share Improve this question asked May 13, 2013 at 15:55 NicoNico 1001 gold badge2 silver badges14 bronze badges1 Answer
Reset to default 4If you're using jQuery, you could do $(window).height()
and then set the iframe height to it.
Drop this into the bottom of your HTML file, just above the closing </body>
tag.
<script src="//ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
;(function($){
$(document).ready(function(){
$('iframe').height( $(window).height() );
$(window).resize(function(){
$('iframe').height( $(this).height() );
});
});
})(jQuery);
</script>
Is it possible to adjust the height of the iframe scroll according to the size of the screen (browser)? It would be like simply replacing the default browser scroll with the iframe scroll. Here is what I mean by this:
I currently have my browser scroll disabled:
<style type="text/css">
html, body {
overflow: hidden;
}
</style>
I have my iframe:
<iframe width="100%" src="" scrolling="yes" frameborder="0" height="100%">
</iframe>
With width set to 100% the iframe scroll bar is pushed to the far right somewhat replacing the default browser scroll bar and my iframe is now the center piece of the website, (yahoo is an example). I can always adjust the height of the iframe to fit my specific browser size however is there a way I set the iframe scroll according to the browser height automatically? Make it responsive to the browser height just like it is to the width?
Is it possible to adjust the height of the iframe scroll according to the size of the screen (browser)? It would be like simply replacing the default browser scroll with the iframe scroll. Here is what I mean by this:
I currently have my browser scroll disabled:
<style type="text/css">
html, body {
overflow: hidden;
}
</style>
I have my iframe:
<iframe width="100%" src="http://www.yahoo." scrolling="yes" frameborder="0" height="100%">
</iframe>
With width set to 100% the iframe scroll bar is pushed to the far right somewhat replacing the default browser scroll bar and my iframe is now the center piece of the website, (yahoo is an example). I can always adjust the height of the iframe to fit my specific browser size however is there a way I set the iframe scroll according to the browser height automatically? Make it responsive to the browser height just like it is to the width?
Share Improve this question asked May 13, 2013 at 15:55 NicoNico 1001 gold badge2 silver badges14 bronze badges1 Answer
Reset to default 4If you're using jQuery, you could do $(window).height()
and then set the iframe height to it.
Drop this into the bottom of your HTML file, just above the closing </body>
tag.
<script src="//ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
;(function($){
$(document).ready(function(){
$('iframe').height( $(window).height() );
$(window).resize(function(){
$('iframe').height( $(this).height() );
});
});
})(jQuery);
</script>
本文标签: javascriptAdjust iframe scroll to height of screen resolutionStack Overflow
版权声明:本文标题:javascript - Adjust iframe scroll to height of screen resolution - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745626377a2159887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论