• 【iframe__窗口】iframe大小随浏览器窗口大小而改变


    iframe大小随浏览器窗口大小而改变

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>iframe</title>
    </head>
    <body>
        <iframe id="mainiframe" style="background-color:red"></iframe>
        <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
        <script type="text/javascript">
            window.onresize = function () { changeFrameHeight(); }
    
            $(function () {
                changeFrameHeight();
            });
    
            $(document).ready(function () {
                //var url = getCookie('pre_url');
                //if (url) {
                //    $("#mainiframe").attr('src', url);
                //} else {
                //    $("#mainiframe").attr('src', '');
                //}
            });
    
            function changeFrameHeight() {
                var ifm = document.getElementById("mainiframe");
                ifm.height = document.documentElement.clientHeight - 100;
                ifm.width = document.documentElement.clientWidth - 100;
                console.log("document.documentElement.clientWidth", document.documentElement.clientWidth);
                console.log("document.documentElement.clientHeight", document.documentElement.clientHeight);
            }
    
            function check() {
                pre_url = window.frames['mainiframe'].document.location.pathname;
                if (pre_url.indexOf("blank") == -1) {
                    setCookie('pre_url', pre_url, 10);
                }
            }
    
            function getCookie(c_name) {
                if (document.cookie.length > 0) {
                    c_start = document.cookie.indexOf(c_name + "=")
                    if (c_start != -1) {
                        c_start = c_start + c_name.length + 1
                        c_end = document.cookie.indexOf(";", c_start)
                        if (c_end == -1) c_end = document.cookie.length
                        return unescape(document.cookie.substring(c_start, c_end))
                    }
                }
                return ""
            }
    
            function setCookie(c_name, value, expiredays) {
                var exdate = new Date()
                exdate.setDate(exdate.getDate() + expiredays)
                document.cookie = c_name + "=" + escape(value) +
                    ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toGMTString())
            }
        </script>
    </body>
    </html>
    
  • 相关阅读:
    XML时代离我们有多远?
    关注程序员健康之——最佳答案梅核气
    巾帼不让须眉 IT界10大女性CEO排行
    网站?XML?我的思考
    企业建站代码HTML滚动文字代码(垂直)
    web前端工程师:WEB标准,Web前端开发工程师必备技术列表
    数据库开发
    面向.NET 的XML 程序设计
    脾与胃病辨证
    技术部工作中常见问题(o_company)
  • 原文地址:https://www.cnblogs.com/kikyoqiang/p/13081254.html
Copyright © 2020-2023  润新知