• 向页面添加多个iframe时高度自适应


    后台代码如下:

    /**
     * 办理足迹登记、移送、交办、确认、退回统一详情页
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
     @RequestMapping(value = "commonGet")
     public ModelAndView commonGet(HttpServletRequest request, HttpServletResponse response) throws Exception {
         ModelAndView mv = this.getAutoView();
    	Long caseId = RequestUtil.getLong(request, "caseId");
    	String caseType = RequestUtil.getString(request, "caseType");
    	String stepType = RequestUtil.getString(request, "stepType");
    	Map map = new HashMap();
    	if("2".equals(caseType)){
    		List<ClueCaseinfo> clueCaseinfoList = clueCaseinfoService.getByClueId(caseId);
    		for (int i = 0; i < clueCaseinfoList.size(); i++) {
    			CaseJudge caseJudge = caseJudgeService.getByCaseIdAndCaseType(Long.valueOf(clueCaseinfoList.get(i).getCaseId()), String.valueOf(clueCaseinfoList.get(i).getCaseType()));
    			OurClueHistory ourClueHistory = ourClueHistoryService.getByClueIdAndStepType(caseJudge.getJudgeId(),stepType);
    			if(ourClueHistory != null){
    				map.put(ourClueHistory.getId(),caseJudge);
    			}
    		}
    	}else{
    		CaseJudge caseJudge = caseJudgeService.getByCaseIdAndCaseType(Long.valueOf(caseId), String.valueOf(caseType));
    		OurClueHistory ourClueHistory = ourClueHistoryService.getByClueIdAndStepType(caseJudge.getJudgeId(),stepType);
    		if(ourClueHistory != null){
    			map.put(ourClueHistory.getId(),caseJudge);
    		}
    	}
    	return mv.addObject("map", map);
    }
    

    前台代码如下(红色为主要代码):

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    	pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <title>办理足迹登记、移送、交办、确认、退回共用详情</title>
    <%@include file="/commons/include/newGet.jsp"%>
    <script type="text/javascript">
    	
    	$(function(){
    		<c:forEach items="${map}" var="m">
    			judgeClueDetail(${m.key},${m.value.caseId},${m.value.caseType})
    		</c:forEach>
    	})
    	
    	function setIframeHeight(iframe) {
    		if (iframe) {
    			var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
    			if (iframeWin.document.body) {
    				iframe.height = (iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight)+15;
    			}
    		}
    	}
    
    	//详情
          function judgeClueDetail(ourClueHistoryId,caseId,caseType){
              var _url = "${ctx}/pwlp/judge/caseJudge/get.ht?clueHistoryId="+ourClueHistoryId+"&caseId="+caseId+"&caseType="+caseType+"&timeLineFlag=yes";
          	  //添加iframe标签
              var body = document.getElementsByTagName("body");
              var div = document.createElement("div");
              div.innerHTML = "<iframe src='"+_url+"' frameborder='0' scrolling='no' style='100%; padding-bottom:0px' onload='setIframeHeight(this)'></iframe>";
              document.body.appendChild(div);
          }
    </script>
    </head>
    <body style="background: #f4f4f4">
    	
    </body>

      

  • 相关阅读:
    动态规划_leetcode70
    动态规划_leetcode64
    动态规划_leetcode63
    PHP处理base64编码字符串
    PHP解决h5页面跨域
    PHP对象转数组
    jQuery 正则
    mysql重置密码
    yii框架学习(获取插入后的id)
    nginx 之 root和alias
  • 原文地址:https://www.cnblogs.com/henuyuxiang/p/12806934.html
Copyright © 2020-2023  润新知