jquery实现iframe自适应高度代码
2013-09-05 20:23
796 查看
iframe框架高度自适应功能在以前我们都是利用js来实现,现在有了jquery控制可以快速实现,下面来看实现有需要的朋友可以看看。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>jquery » iframe sizing</title>
<link rel="stylesheet" type="text/css教程" media="all" href="css/master.css" />
<script type="text/网页特效" src="js/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="js/jquery.iframe-auto-height.plugin.js"></script>
</head>
<body>
<div id="container">
<h1>
jquery » iframe sizing
</h1>
<p>
this demo uses <a href="http://jquery.com/">jquery</a> to dynamically size iframes based on content height.
original code by nathan smith, see <a href="http://sonspring.com/journal/jquery-iframe-sizing">original article</a>.
</p>
<p>
now a jquery plugin, download from github <a href="http://github.com/house9/jquery-iframe-auto-height">http://github.com/house9/jquery-iframe-auto-height</a>
and view the readme file.
</p>
<p>
best viewed locally with firefox.
|
<a href="index2.html">index2</a>
|
<a href="index_with_tables.html">index_with_tables</a>
</p>
<iframe src="panoramic.html" class="photo" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<div class="clear"> </div>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<div class="clear"> </div>
</div>
<!-- end #container -->
<script type="text/javascript">
// match all iframes / use jquery or alias $
jquery('iframe').iframeautoheight();
// only panoramic.html iframe with some extra height
// $('iframe.photo').iframeautoheight({heightoffset: 50});
// notes: you can wrap this in document ready if you like
// but ie8 didn't always like it
</script>
</body>
</html>
这样做起比较js要方便了许多,并且我们只要利用 jquery('iframe').iframeautoheight();来自适应高度就可以了。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>jquery » iframe sizing</title>
<link rel="stylesheet" type="text/css教程" media="all" href="css/master.css" />
<script type="text/网页特效" src="js/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="js/jquery.iframe-auto-height.plugin.js"></script>
</head>
<body>
<div id="container">
<h1>
jquery » iframe sizing
</h1>
<p>
this demo uses <a href="http://jquery.com/">jquery</a> to dynamically size iframes based on content height.
original code by nathan smith, see <a href="http://sonspring.com/journal/jquery-iframe-sizing">original article</a>.
</p>
<p>
now a jquery plugin, download from github <a href="http://github.com/house9/jquery-iframe-auto-height">http://github.com/house9/jquery-iframe-auto-height</a>
and view the readme file.
</p>
<p>
best viewed locally with firefox.
|
<a href="index2.html">index2</a>
|
<a href="index_with_tables.html">index_with_tables</a>
</p>
<iframe src="panoramic.html" class="photo" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe>
<div class="clear"> </div>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<iframe src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe>
<div class="clear"> </div>
</div>
<!-- end #container -->
<script type="text/javascript">
// match all iframes / use jquery or alias $
jquery('iframe').iframeautoheight();
// only panoramic.html iframe with some extra height
// $('iframe.photo').iframeautoheight({heightoffset: 50});
// notes: you can wrap this in document ready if you like
// but ie8 didn't always like it
</script>
</body>
</html>
这样做起比较js要方便了许多,并且我们只要利用 jquery('iframe').iframeautoheight();来自适应高度就可以了。
相关文章推荐
- 基于jQuery实现左右div自适应高度完全相同的代码
- Jquery与JS两种方法仿twitter/新浪微博 高度自适应无缝滚动实现代码
- jquery 实现iframe 自适应高度
- jquery实现Iframe高度自适应(兼容多浏览)
- jquery iframe自适应高度代码(浏览器兼容)
- jquery 实现iframe 自适应高度
- jquery 实现iframe 自适应高度
- IFrame跨域高度自适应实现代码
- jQuery实现iframe的自适应高度
- Jquery与JS两种方法仿twitter/新浪微博 高度自适应无缝滚动实现代码
- jquery iframe自适应高度代码(浏览器兼容)
- jQuery解决iframe高度自适应代码
- jquery 实现iframe 自适应高度
- jquery 实现iframe 自适应高度
- jquery 实现iframe 自适应高度
- 两段超简单jquery代码解决iframe自适应高度问题(不用判断浏览器高度)
- jquery实现iframe自适应高度
- jquery 实现iframe 自适应高度
- jquery 实现iframe 自适应高度
- jquery 实现iframe 自适应高度