Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

iframe大小控制

$
0
0

<iframe src="${basePath}supercenter/webs/secondLevel.jsp" frameborder="0"
   scrolling="no" id="stepForm" name="stepForm"
   style="width: 100%;height:0px;" >
  </iframe>

 

 

<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="${basePath}style/${systemSubType}/css/default/Styles.css " rel="stylesheet" type ="text/css"/></link>
<link href="${basePath}style/${systemSubType}/css/default/StylesBack.css " rel="stylesheet" type ="text/css"/></link>
<link href="${basePath}style/${systemSubType}/css/default/public.css" rel="stylesheet"  type="text/css"/></link>
    <title>右边</title>
 <style>
 body,html{height:100%;}
 #div_pannel{margin-left:auto;margin-right:auto;}
 *{margin:0;padding:0;}
 #div_tab{background:#fff url(${basePath}style/${systemSubType}/images/default/back/t_tab_bg.gif) repeat-x 0 bottom;height:26px;margin-bottom:2px;margin-left:auto;margin-right:auto;}
 #div_tab li{float:left;text-align:center;position:relative;list-style:none;}
 
 #div_tab li{background:url(${basePath}style/${systemSubType}/images/default/back/t_tab_uselectbg.gif);margin-top:3px;height:23px;}
 #div_tab li span{background:url(${basePath}style/${systemSubType}/images/default/back/t_tab_uselectbg.gif);height:23px;line-height:23px;}
 
 #div_tab li.crent{background:url(${basePath}style/${systemSubType}/images/default/back/t_tab_selectbg.gif);margin-top:2px;height:24px;}
 #div_tab li.crent span{background:url(${basePath}style/${systemSubType}/images/default/back/t_tab_selectbg.gif);height:24px;line-height:24px;}
 
 #div_tab li,#div_tab li.crent{color:#fff;background-repeat:no-repeat;background-position:0 0;} 
 #div_tab li span,#div_tab li.crent span{display:inline-block;padding:0 36px 0 15px;background-repeat:no-repeat;background-position:right bottom;}
 
 #div_tab li .menua{color:#000;font-size:12px; text-decoration:none;position:relative;}
 #div_tab li.crent .menua,#div_tab li .menua:hover{color:#ff0000;}
 #div_tab li .win_close,#div_tab li.crent .win_close{width:14px;height:14px;position:absolute;top:4px;right:5px;cursor:pointer;display:block;overflow:hidden;background:url(${basePath}style/${systemSubType}/images/default/back/t_delete_ico.gif) no-repeat;}  
 #div_tab li .win_close{background-position:0 -14px;}
 #div_tab li .win_close:hover{background-position:0 0;}  
 
 .clearfix:after {content:"."; display:block;height:0;clear:both; visibility:hidden;}
 *html .clearfix{height:1%;width:985px;}
 *+html .clearfix{height:1%;}
 .clearfix{display:inline-block;width:985px;}
 /* Hide from IE Mac */
 .clearfix {display:block;width:990px;}
 </style>
    <script type="text/javascript">
   
      var b_v=navigator.appVersion;
      var IE6=b_v.search(/MSIE 6/i)!=-1;
      //不刷新数据
      function CreateNewTab(tabid, url, name){
       CreateDiv(tabid, url, name,1,0);
      }
      //会刷新数据
      function CreateRfreshTab(tabid, url, name){
       CreateDiv(tabid, url, name,1,1);
      }
      function CreateDiv(tabid, url, name,hasDelete,isRefresh)
   {
    if(isRefresh==1){
     if(document.getElementById("div_" + tabid) != null)RemoveDiv(tabid);
    }
   ///如果当前tabid存在直接显示已经打开的tab
   if (document.getElementById("div_" + tabid) == null)
   {
    //创建iframe
    var box = document.createElement("iframe");
    box.id = "div_" + tabid;
    box.name="div_" + tabid;
    box.src = url;
    box.height = "100%";
    box.frameBorder = 0;
    box.width = "100%";
    
    
    document.getElementById("div_pannel").appendChild(box);
    
    //遍历并清除开始存在的tab当前效果并隐藏其显示的div
    var tablist = document.getElementById("div_tab").getElementsByTagName('li');
    var pannellist = document.getElementById("div_pannel").getElementsByTagName('iframe');
    var tabswidth=0;
    if (tablist.length > 0)
    {
     for (i = 0; i < tablist.length; i++)
     {
      tablist[i].className = "";
      tabswidth+=eval(tablist[i].scrollWidth);
      pannellist[i].style.display = "none";
     }
    }
    //创建li菜单
    var tab = document.createElement("li");
    tab.className = "crent";
    tab.id = tabid;
    if (window.ActiveXObject)//IE
    tab.onclick = function() {CreateDiv( tabid , url , name); }
    var winClose="";
    var ondblClickEvent="";
    //yulon add 双击事件
    if(hasDelete==1){
     winClose="<a onclick=\"RemoveDiv('" + tabid + "')\" class=\"win_close\" title=\"关闭当前窗口\"><a>";
     ondblClickEvent="title='双击可关闭' ondblClick=\"RemoveDiv('" + tabid + "')\"";
    }
    var litxt = "<span "+ondblClickEvent+"><a href=\"javascript:;\" onclick=\"javascript:CreateDiv('" + tabid + "','" + url + "','" + name + "',1,1)\" title=" + name + " class=\"menua\">" + name + "</a>"+winClose+"</span>";
    tab.innerHTML = litxt;
    tabswidth+=tab.scrollWidth;
    //yulon add差值
    var dvalue=eval(document.getElementById("div_tab").scrollWidth)-tabswidth;
    if(tablist.length>2&&dvalue<210){
     for (i = 1; i < tablist.length; i++)
     {
      if(tablist[i].style.display != "none"){
      tablist[i].className = "";
      tablist[i].style.display= "none";
      pannellist[i].style.display = "none";
      break;
      }
     }
    }
    document.getElementById("div_tab").appendChild(tab);
    //if(IE6){
    //}
    $("#div_" + tabid).load(function() { //alert("sfsdsf");
     var iframeHeight = Math.min(box.contentWindow.window.document.documentElement.scrollHeight, box.contentWindow.window.document.body.scrollHeight);
     if(iframeHeight <= 300)
     {
      iframeHeight +=300;
     }
     iframeHeight+=10;
     $(this).height(iframeHeight);
     $("#div_pannel").height(iframeHeight);
    });
    
     document.frames("div_"+tabid).location.reload(); //解决ie6动态创建iframe问题
   }
   else
   {
    var tablist = document.getElementById("div_tab").getElementsByTagName('li');
    var pannellist = document.getElementById("div_pannel").getElementsByTagName('iframe');
    var tabswidth=0;
    for (i = 0; i < tablist.length; i++)
    {
     tablist[i].className = "";
     if(tablist[i].style.display != "none"){
       tabswidth+=eval(tablist[i].scrollWidth);
     }
     pannellist[i].style.display = "none"
    }
    document.getElementById(tabid).className = 'crent';
    tabswidth+=document.getElementById(tabid).scrollWidth;
    //yulon add差值
    var dvalue=eval(document.getElementById("div_tab").scrollWidth)-tabswidth;
    if(tablist.length>2&&dvalue<210){
     for (i = 1; i < tablist.length; i++)
     {
      if(tablist[i].style.display != "none"){
       tablist[i].className = "";
       tablist[i].style.display= "none";
       pannellist[i].style.display = "none";
       break;
      }
     }
    }
    document.getElementById(tabid).style.display = 'block';
    document.getElementById("div_" + tabid).style.display = 'block';
    $("#div_" + tabid).load(function() { //alert("sfsdsf");
     var iframeHeight = Math.min(box.contentWindow.window.document.documentElement.scrollHeight, box.contentWindow.window.document.body.scrollHeight);
     if(iframeHeight <= 300)
     {
      iframeHeight +=300;
     }
     iframeHeight+=10;
     $(this).height(iframeHeight);
     $("#div_pannel").height(iframeHeight);
    });
    
   }
   
   
  }
  function RemoveDiv(obj)
   {
   var ob = document.getElementById(obj);
   ob.parentNode.removeChild(ob);
   var obdiv = document.getElementById("div_" + obj);
   obdiv.parentNode.removeChild(obdiv);
   var tablist = document.getElementById("div_tab").getElementsByTagName('li');
   var pannellist = document.getElementById("div_pannel").getElementsByTagName('iframe');
   if (tablist.length > 0)
   {
    tablist[tablist.length - 1].className = 'crent';
    tablist[tablist.length - 1].style.display = 'block';
    pannellist[tablist.length - 1].style.display = 'block';
   }
   //yulon add
   for (i = tablist.length-1; i > 0; i--)
    {
     if(tablist[i].style.display == "none"){
      tablist[i].className = "";
      tablist[i].style.display= "block";
      break;
     }
    }  
  }
  window.onload=function(){
   CreateDiv('desktop','${basePath}saas/index.action?template=backgroundMain&SystemType=${SystemType}&systemSubType=${systemSubType}','桌面',1);
  }
  onclick="CreateTab('${item2.name }','${item2.URL1}','${item2.name}')"
  
  
function createwin(tabname,url,title){
 CreateRfreshTab(tabname,url,title,1);
}
    </script>
</head>
<body>
<div class="topborder"></div>
<div class="servicedoorwidth"> 
 <jsp:include page="top.jsp"></jsp:include>
 
 <ul class="clearfix" id="div_tab" style="width:990px;"></ul>
    <div id="div_pannel" style="width:990px;"></div>
 <jsp:include page="bottom.jsp"></jsp:include>
</div>
</body>

作者:niuch1029291561 发表于2013-1-14 16:34:56 原文链接
阅读:30 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>