• 设置window.open窗口页面title


    index.html---------------------------------------------------------------

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>window.open</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <body>
    <button id="btn" type="button">按钮打开window.open</button>
    </body>
    </html>
    <script type="text/javascript">
    $(function(){
    $("#btn").click(function(){
    // 设置open页面title
    var setOpenTile = "设置title"
    // 设置窗口宽度
    var iwidth = 1200
    // 设置窗口高度
    var iheight = 600
    //获得窗口的垂直位置
    var iTop = (window.screen.availHeight - 30 - iheight) / 2;
    //获得窗口的水平位置
    var iLeft = (window.screen.availWidth - 10 - iwidth) / 2;
    window.open("open.html","setTitle","height="+iheight+", width="+iwidth+",top="+iTop+",left="+iLeft+",toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=no,status=no");
    // 定义全局变量给open页面调用
    window.getTitleFun = setOpenTile
    })
    })
    </script>

    open.html---------------------------------------------------------------

    <!DOCTYPE html>
    <html lang="zh">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>openTitle</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    </head>
    <body>
    <button type="button" >确定</button>
    </body>
    </html>
    <script type="text/javascript">
    window.onload=function(){
    if (window.opener != null) {
    document.title = window.opener.getTitleFun;
    }
    }
    </script>

  • 相关阅读:
    xxx端口被占用怎么办?
    JavaScript复习--JavaScript的特点和作用
    JavaScript复习--点击按钮,div边框(宽和高)动态增加
    JavaScript复习--评分控件(类似于淘宝给好差平的星星)
    canvas 小记
    overrideMimeType ,接口blob数据转成 base64格式;
    编写一个webpack插件
    html中资源加载优化
    css content 可以怎么用
    关于promise的思考
  • 原文地址:https://www.cnblogs.com/onceweb/p/13861826.html
Copyright © 2020-2023  润新知