jsp中的iframe:
<iframe src="/mobile/parents/remote/$!{ency.contentUrl}index.html" id="ifr" align="center" width="100%" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
js对iframe的控制
$('#ifr').load(function(){
/*var $head = $(this).contents().find('head');
$head.append("<link rel='stylesheet' href='../../../../themes/mobile/parents/content.css' />");*/
var width = $('#detail-article').width();
$(this).contents().find('img,iframe').each(function(){
if($(this).width() >=width ) {
$(this).width(width-10);
}
});
var mainheight = $(this).contents().find('body').height()+30;
$(this).height(mainheight);
});
上面的iframe中src配置的还是本地的请求路径,非远程的路径,不存在跨域的问题,参考:
http://felix-alone2012.iteye.com/admin/blogs/2181789
js中对iframe中html内容的尺寸进行了控制
本文介绍如何在JS中控制Iframe中的HTML内容尺寸,并解决本地请求路径下的跨域问题,通过实例展示了跨域请求的配置及对Iframe内容尺寸的动态调整。
3762

被折叠的 条评论
为什么被折叠?



