`

用iframe加载http远程资源

    博客分类:
  • http
 
阅读更多

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内容的尺寸进行了控制

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics