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

后台代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * 办理足迹登记、移送、交办、确认、退回统一详情页
 * @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);
}

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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%@ 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 h = $(window).height();
                        //iframe.height = h;
 
            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='width:100%; padding-bottom:0px' onload='setIframeHeight(this)'></iframe>";
          document.body.appendChild(div);
      }
</script>
</head>
<body style="background: #f4f4f4">
     
</body>

 

 

  

posted @   岁月淡忘了谁  阅读(811)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示