zoukankan      html  css  js  c++  java
  • DHTML_____window对象方法

    <html>
    <head>
      <meta charset="utf-8">
      <title>window对象方法</title>
    </head>
    
    <body>
    <div style="text-align:center;text-">Window对象的方法</div>
    <div id="divId"></div>
    <input type="button" value="取消间歇定时器" onclick="clearInter()"/>
    
    <input type="button" value="打开新窗口" onclick="moveWin()"/>
    
    <input type="button" value="改变浏览器窗口大小" onclick="resizeWin()"/>
    
    <input type="button" value="打开新窗口" onclick="openWin()"/>
    
    <input type="button" value="新窗口自动关闭" onclick="testWin()"/>
    
    <input type="button" value="模态对话框自动关闭" onclick="testDialog()"/>
    
    <script language="javascript">
    //01alert
    //window.alert("alert!!!");
    
    //02  确认对话框
    //window.confirm("???");
    
    //03 输入信息对话框
    //window.prompt("提示信息","默认值");
    
    //04 close() 关闭当前浏览器窗口
    //window.close();
    
    //05  导航到指定URL资源
    //window.navigate("http://www.baidu.com");
    //window.navigate('http://www.baidu.com');
    
    //06 间歇定时器
    var int=setInterval("inner()",2000);
    var s="";
    function inner(){
        var div=document.getElementById("divId");
        s+="Hello World!!!<br/>";
        div.innerHTML=s;
    }
    
    //07  定时计时器
    //setTimeout('inner()',5000);
    
    //08 取消间歇定时器    
    //即使得当前间歇计时器停止执行,执行过的内容仍在
    function clearInter(){
        window.clearInterval(int);
    }
    
    //09 取消定时计时器  参数为计时器变量
    //window.clearTimeout(int);
    
    //10 移动浏览器窗口到指定的屏幕位置
    //在IE浏览器中有效
    function moveWin(){
        myWin=window.open('http://www.baidu.com','_blank','width=200,height=100');
        myWin.document.write("新窗口!!!");
        myWin.moveTo(0,0);
        myWin.focus();
    }
    
    //11 改变浏览器窗口大小
    function resizeWin(){
        window.resizeTo(400,400);
    }
    
    //12 打开新窗口
    function openWin(){
        window.open('http://www.baidu.com','_blank','top=10,left=0,toolbar=no,width=100,height=100');
    }
    
    //13  模态对话框窗口   必须关闭模态对话框才能在原始网页窗口进行操作
    //window.showModalDialog('http://www.baidu.com','zhangsan');
    
    //14  非模态对话框窗口  不用关闭模态对话框也能在原始网页窗口进行操作
    //window.showModelessDialog('http://www.baidu.com','zhangsan');
    
    //测试打开一个小窗口  5秒后自动关闭
    function testWin(){
        myWin=window.open("./test02.html","_blank","width=100,height=100");
        myWin.moveTo(0,0);
        setTimeout("myWin.close()",5000);    
    }
    
    function testDialog(){
        var myDialog=window.showModalDialog();
        setTimeout('myDialog.close()',5000);
        //
    }
    </script>
    </body>
    </html>
    View Code
     1 <html>
     2 <head>
     3   <meta charset="utf-8">
     4   <title>window对象方法</title>
     5 </head>
     6 
     7 <body>
     8 <div style="text-align:center;text-">Window对象的方法</div>
     9 <div id="divId"></div>
    10 <input type="button" value="取消间歇定时器" onclick="clearInter()"/>
    11 
    12 <input type="button" value="打开新窗口" onclick="moveWin()"/>
    13 
    14 <input type="button" value="改变浏览器窗口大小" onclick="resizeWin()"/>
    15 
    16 <input type="button" value="打开新窗口" onclick="openWin()"/>
    17 
    18 <input type="button" value="新窗口自动关闭" onclick="testWin()"/>
    19 
    20 <input type="button" value="模态对话框自动关闭" onclick="testDialog()"/>
    21 
    22 <script language="javascript">
    23 //01alert
    24 //window.alert("alert!!!");
    25 
    26 //02  确认对话框
    27 //window.confirm("???");
    28 
    29 //03 输入信息对话框
    30 //window.prompt("提示信息","默认值");
    31 
    32 //04 close() 关闭当前浏览器窗口
    33 //window.close();
    34 
    35 //05  导航到指定URL资源
    36 //window.navigate("http://www.baidu.com");
    37 //window.navigate('http://www.baidu.com');
    38 
    39 //06 间歇定时器
    40 var int=setInterval("inner()",2000);
    41 var s="";
    42 function inner(){
    43     var div=document.getElementById("divId");
    44     s+="Hello World!!!<br/>";
    45     div.innerHTML=s;
    46 }
    47 
    48 //07  定时计时器
    49 //setTimeout('inner()',5000);
    50 
    51 //08 取消间歇定时器    
    52 //即使得当前间歇计时器停止执行,执行过的内容仍在
    53 function clearInter(){
    54     window.clearInterval(int);
    55 }
    56 
    57 //09 取消定时计时器  参数为计时器变量
    58 //window.clearTimeout(int);
    59 
    60 //10 移动浏览器窗口到指定的屏幕位置
    61 //在IE浏览器中有效
    62 function moveWin(){
    63     myWin=window.open('http://www.baidu.com','_blank','width=200,height=100');
    64     myWin.document.write("新窗口!!!");
    65     myWin.moveTo(0,0);
    66     myWin.focus();
    67 }
    68 
    69 //11 改变浏览器窗口大小
    70 function resizeWin(){
    71     window.resizeTo(400,400);
    72 }
    73 
    74 //12 打开新窗口
    75 function openWin(){
    76     window.open('http://www.baidu.com','_blank','top=10,left=0,toolbar=no,width=100,height=100');
    77 }
    78 
    79 //13  模态对话框窗口   必须关闭模态对话框才能在原始网页窗口进行操作
    80 //window.showModalDialog('http://www.baidu.com','zhangsan');
    81 
    82 //14  非模态对话框窗口  不用关闭模态对话框也能在原始网页窗口进行操作
    83 //window.showModelessDialog('http://www.baidu.com','zhangsan');
    84 
    85 //测试打开一个小窗口  5秒后自动关闭
    86 function testWin(){
    87     myWin=window.open("./test02.html","_blank","width=100,height=100");
    88     myWin.moveTo(0,0);
    89     setTimeout("myWin.close()",5000);    
    90 }
    91 
    92 function testDialog(){
    93     var myDialog=window.showModalDialog();
    94     setTimeout('myDialog.close()',5000);
    95     //
    96 }
    97 </script>
    98 </body>
    99 </html>
  • 相关阅读:
    软件工程第一次作业
    软件工程第五次作业——结对编程 小学四则运算自动生成程序
    软件工程第四次作业——结对编程第一次作业
    软件工程第三次作业——最大连续子数组和
    软件工程——第二次作业
    第一篇博客——我的大学
    结对编程第二次作业
    结对编程第一次作业
    软件工程第三次作业
    软件工程第二次作业
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/6076977.html
Copyright © 2011-2022 走看看