iframe自适应高度?

1. 下载代码jquery-auto-iframe-height或者下载

2. 使用demo

<!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" mce_href="css/master.css" /> <mce:script type="text/javascript" src="js/jquery-1.4.3.min.js" mce_src="js/jquery-1.4.3.min.js"></mce:script> <mce:script type="text/javascript" src="js/jquery.iframe-auto-height.plugin.js" mce_src="js/jquery.iframe-auto-height.plugin.js"></mce:script> </head> <body> <div id="container"> <h1> jQuery » iFrame Sizing </h1> <p> This demo uses <a href="http://jquery.com/" mce_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" mce_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" mce_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" mce_href="index2.html">index2</a> | <a href="index_with_tables.html" mce_href="index_with_tables.html">index_with_tables</a> </p> <iframe src="panoramic.html" mce_src="panoramic.html" class="photo" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_1.html" mce_src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_1.html" mce_src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_1.html" mce_src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_1.html" mce_src="iframe_1.html" class="column" scrolling="no" frameborder="0"></iframe> <div class="clear"></div> <iframe src="iframe_2.html" mce_src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_2.html" mce_src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_2.html" mce_src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe> <iframe src="iframe_2.html" mce_src="iframe_2.html" class="column" scrolling="no" frameborder="0"></iframe> <div class="clear"></div> </div> <!-- end #container --> <mce: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 // --></mce:script> <!-- on chrome on mac get this error when viewing locally Unsafe JavaScript attempt to access frame with U RL file:///.../jquery-iframe-auto-height/iframe_2.html from frame with URL file:///.../jquery-iframe-auto-height/index.html. Domains, protocols and ports must match. should be fine when code is served from a web server view with firefox locally --> </body> </html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值