<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    vjame

    優(yōu)化代碼是無(wú)止境的
    隨筆 - 65, 文章 - 9, 評(píng)論 - 26, 引用 - 0
    數(shù)據(jù)加載中……

    jquery ui tabs iframe 高度 寬度自適應(yīng)

      1<%@ page contentType="text/html; charset=UTF-8" language="java" %>
      2<%@ taglib prefix="s" uri="/struts-tags" %>
      3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      4<html xmlns="http://www.w3.org/1999/xhtml">
      5<head>
      6<title>temp_title</title>
      7    <%@ include file="/ui/common.jsp"%>
      8    <%@ include file="/ui/components/jquery-ui/jquery-uiHead.jsp"%>
      9    <script type="text/javascript">
     10     $(document).ready(function(){
     11         
     12         var browser = navigator.appName;
     13         var heightAdjust = 23;
     14         var widthAdjust = 7+20;
     15         
     16         // Make height and width offset adjusts for non-IE browsers 
     17         if (browser != "Microsoft Internet Explorer")
     18         {
     19             heightAdjust = 18;
     20             widthAdjust = 9+20;
     21         }

     22     
     23        $("#tabs").tabs({
     24            cache: true// This ensures selecting a tab does not refresh the page
     25            load: function(event, ui)
     26            {
     27               // Keep links, form submissions, etc. contained within the tab
     28               //$(ui.panel).hijack();
     29               
     30               // Adjust the IFRAME size correctly in the browser window
     31               $('.contentsIframe').width((ViewPortWidth() - widthAdjust));
     32               $('.contentsIframe').height((ViewPortHeight() - $('#tabs_ul').height() - heightAdjust));
     33            }

     34        }
    );
     35        
     36        $("#tabs_ul li").click(function(){
     37            var flag = false;
     38            var tabId = $(this).attr("id");
     39            var selectedItems = $("#tabs_ul li.selected");
     40            if(selectedItems.length > 0){
     41                var selectedItemId = selectedItems[0].id;
     42                if(tabId != selectedItemId)// 尚未選中
     43                    flag = true;
     44                }

     45            }
     else {
     46                flag = true;
     47            }

     48            
     49            
     50            if(flag){
     51                $(this).addClass("hover");
     52                $(this).siblings().removeClass("hover");
     53                
     54                var url = "";
     55                if(tabId == "grant_menu"){
     56                    url = temp_ur1l;
     57                }
     else if(tabId == "grant_business"){
     58                    url = temp_ur12;
     59                }
     else if(tabId == "grant_resource"){
     60                    url = temp_ur13;
     61                }
    else{
     62                    return;
     63                }

     64                $("#grant_iframe").attr("src", url);
     65            }

     66        }
    );
     67        $("#tabs_ul li")[0].click();
     68        
     69        // Adjust tab header width and visible iframe window height and width after the window is resized
     70        $(window).resize(function(){
     71            $('#grant_iframe').width((ViewPortWidth() - widthAdjust));
     72            $('#grant_iframe').height((ViewPortHeight() - $('#tabs_ul').height() - heightAdjust));
     73        }
    );
     74        
     75        // Adjust the IFRAME height correctly in the browser window
     76        $('#grant_iframe').height((ViewPortHeight() - $('#tabs_ul').height() - heightAdjust));
     77        
     78    }
    );
     79    
     80    // Returns width of viewable area in the browser
     81    function ViewPortWidth()
     82    {
     83        var width = 0;
     84
     85        if ((document.documentElement) && (document.documentElement.clientWidth)) {
     86            width = document.documentElement.clientWidth;
     87        }

     88        else if ((document.body) && (document.body.clientWidth)) {
     89            width = document.body.clientWidth;
     90        }

     91        else if (window.innerWidth) {
     92            width = window.innerWidth;
     93        }

     94
     95        return width;
     96    }

     97
     98    // Returns height of viewable area in the browser
     99    function ViewPortHeight()
    100    {
    101        var height = 0;
    102
    103        if (window.innerHeight) {
    104            height = window.innerHeight;
    105        }

    106        else if ((document.documentElement) && (document.documentElement.clientHeight)) {
    107            height = document.documentElement.clientHeight;
    108        }

    109
    110        return height;
    111    }

    112    
    113    
    </script>
    114  </head>
    115  <body style="margin:0; overflow:hidden;">
    116    <div id="tabs">
    117        <ul id="tabs_ul">
    118            <li id="grant_menu"><href="#tabs-grant">時(shí)間設(shè)置</a></li>
    119            <li id="grant_business"><href="#tabs-grant">崗位參數(shù)</a></li>
    120            <li id="grant_resource"><href="#tabs-grant">項(xiàng)目參數(shù)</a></li>
    121        </ul>
    122        <div id="tabs-grant" >
    123            <iframe id="grant_iframe" src="" frameborder="0" style="height:100%; width:100%; marginwidth:0; marginheight:0; scrolling:auto" ></iframe>
    124        </div>
    125    </div>
    126  </body>
    127</html>
    128
    129




    1、引用jquery-ui
    2、設(shè)置body樣式margin:0; overflow:hidden;
    3、設(shè)置iframe樣式 height:100%; width:100%; marginwidth:0; marginheight:0; scrolling:auto
    4、設(shè)置窗體resize方法,以及高度的初始化值


    posted on 2013-08-06 09:44 lanjh 閱讀(5594) 評(píng)論(3)  編輯  收藏 所屬分類(lèi): Java Web

    評(píng)論

    # re: jquery ui tabs iframe 高度 寬度自適應(yīng)  回復(fù)  更多評(píng)論   

    謝謝 你的代碼很有用 而且可以在DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd和 Transitional 我式了好多 都不支持 這的 只支持不帶Transitional和strict標(biāo)準(zhǔn)的
    2013-10-28 07:45 | Sn

    # re: jquery ui tabs iframe 高度 寬度自適應(yīng)  回復(fù)  更多評(píng)論   

    不過(guò) 我現(xiàn)在 還不知道差了4個(gè)像素在哪里 可能是2個(gè)Div的邊框吧 我用border:0px去掉不行
    2013-10-28 07:48 | Sn

    # re: jquery ui tabs iframe 高度 寬度自適應(yīng)  回復(fù)  更多評(píng)論   

    我現(xiàn)在做的是讓iframe可視化界面顯示隨窗口大小變動(dòng)而變的
    <iframe w=100% h=100%></iframe><div position:relative><div position:fixed>內(nèi)容是浮在iframe上面</div></div> 主窗口頁(yè)面沒(méi)滾動(dòng)條的用是iframe的滾動(dòng)條 現(xiàn)在就不知道怎么差了4個(gè)像素
    2013-10-28 08:00 | Sn
    主站蜘蛛池模板: 成人毛片18女人毛片免费视频未| 美女被免费喷白浆视频| 免费无码又爽又刺激聊天APP| 四虎国产精品免费久久影院| 亚洲AV无码乱码国产麻豆穿越| 亚洲最大无码中文字幕| 高清永久免费观看| 免费做爰猛烈吃奶摸视频在线观看| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 亚洲字幕在线观看| 一级毛片成人免费看a| 青娱分类视频精品免费2| 亚洲乱码中文字幕综合234| 综合自拍亚洲综合图不卡区| 黄网站色成年片大免费高清| 6080午夜一级毛片免费看| 亚洲成片观看四虎永久| 亚洲成人午夜电影| jzzjzz免费观看大片免费| 思思re热免费精品视频66| 国产亚洲精久久久久久无码77777| 国产精品久久亚洲不卡动漫| 一级免费黄色大片| 精品久久久久久久久免费影院| 亚洲中文字幕日产乱码高清app| 亚洲一区二区三区高清不卡 | 成人免费视频网址| 亚洲av永久无码精品漫画| 日韩欧美亚洲国产精品字幕久久久| 成全高清在线观看免费| 人人狠狠综合久久亚洲高清| 亚洲国产综合人成综合网站00| 中文字幕无码毛片免费看| 最新中文字幕免费视频| 亚洲精品第五页中文字幕| A级毛片成人网站免费看| 日韩精品免费电影| 亚洲av无码电影网| 精品熟女少妇a∨免费久久| 久久久久亚洲精品天堂久久久久久 | 国产成人高清亚洲一区久久|