码迷,mamicode.com
首页 > 其他好文 > 详细

窗口的弹出与关闭

时间:2017-03-09 11:36:39      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:new   this   char   pre   修改   news   charset   htm   innerhtml   

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        body{
            /*margin: 0;*/
        }
        #div1{
            width: 100px;
            height: 100px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
<div id="div1" onmouseover="getInfo(this)" onmouseout="this.innerHTML=‘‘">

</div>
<button onclick="getInfo()">获取div信息</button>

<hr/>
<a href="111.html" target="_blank">我是超链接</a>
<br/><br/>
<button onclick="myopen1()">新窗口111111111</button>
<button onclick="myopen2()">新窗口222222222</button>
<button onclick="myopen3()">新窗口333333333</button>

<hr/>
<button onclick="myclose()">关掉子窗口</button>

<script>
    var mywin;
    function myclose(){
        if(mywin)
            mywin.close();
    }
    function myopen3(){
        mywin = window.open(‘333.html‘, ‘news‘, ‘resizable=no‘);
    }
    function myopen2(){
        mywin = window.open(‘222.html‘, ‘news‘, ‘resizable=no‘);
    }
    function myopen1(){
        mywin = window.open(‘111.html‘, ‘news‘, ‘resizable=no‘);
    }
    function getInfo(obj){
//        var div1 = document.getElementById(‘div1‘);

        obj.innerHTML = obj.offsetWidth+‘,,‘+obj.offsetHeight;
        obj.innerHTML += ‘<br>‘+obj.offsetLeft+‘,,‘+obj.offsetTop;
        // offsetXXX 只能读取不能赋值修改
        obj.offsetWidth = obj.offsetWidth+100;
        // 下面的属性已经不能用了
//        obj.innerHTML += ‘<br>‘+obj.innerWidth+‘,,‘+obj.innerHeight;
    }
</script>
</body>
</html>

弹出窗口,以及关闭窗口

窗口的弹出与关闭

标签:new   this   char   pre   修改   news   charset   htm   innerhtml   

原文地址:http://www.cnblogs.com/zxy945/p/6524381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!