JS复习 DOM

DOM

  可以操作浏览器在桌面上的位置。尺寸。和地址栏。浏览器内部写的div之类的不能操作没有标记的纯文本

  windows对象
    window.open();开启新页面  不要乱用   公开的不要用

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" value="按钮1" id="btn1" />
        </div>
    </form>
</body>
</html>
<script>
    var oBtn1 = document.getElementById("btn1");//获取按钮的id叫oBtn1
    oBtn1.onclick = function () {//点击oBtn1发生的事件
        window.open("Default2.aspx");//源窗口新页面打开
        window.open("Default2.aspx","_blank","width=400 height=400 left=200 top=200")//新窗口打开 宽高个400距离左边上边个200
    }
</script>


    window.close();关闭当前页面在哪个页面执行关闭哪个页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" value="按钮1" id="btn1" />
            <input type="button" value="按钮2" id="btn2" />
        </div>
    </form>
</body>
</html>
<script>
    var a;
    var oBtn1 = document.getElementById("btn1");//获取按钮的id叫oBtn1
    var oBtn2 = document.getElementById("btn2");//获取按钮的id叫oBtn2
    oBtn1.onclick = function () {//点击oBtn1发生的事件
      a=  window.open("Default2.aspx");//源窗口新页面打开 
    }
    oBtn2.onclick = function () {//点击oBtn2发生的事件
        a.close();  //关闭 a=  window.open("Default2.aspx");网页
    }
</script>


    window.opener;父级窗口

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" value="按钮1" id="btn1" />
            
        </div>
    </form>
</body>
</html>
<script>
    document.getElementById("btn1").onclick = function () {
        window.opener.close();//点击按钮关闭父级窗口
    }
</script>


    window.setInterval(“要执行的代码”,“间隔的毫秒数”)间隔一段时间执行代码  / window.setTimeout(间隔的id) 清除间隔执行
   调整页面

    window.navigate("url");  不用
    window.moveTo(x,y);移动相对于IE浏览器有用
    window.resizeTo(wid,hei);相对于IE浏览器有用
    window.scrollTo(x,y);相当于锚点X为横向坐标。Y为纵向坐标

  window.history对象
    window.history.back();按一下后退
    window.history.forward();按一下前进

    window.history.go(n);n为数字  放正数前进n个页面  放负数后退n个页面
  window.location对象
     window.location.href="url";跳转页面只能在当前页面跳转  不会被屏蔽  可以alret获取网页地址

  

 

    

posted @ 2017-08-14 11:16  纡ゾ少︶ㄣ  阅读(106)  评论(0编辑  收藏  举报