zoukankan      html  css  js  c++  java
  • js复习:

         JavaScript:  基本语法:  与c#语法基本一致,类型转换:var a= parseint(值): var b = parsefloat(值);     isNaN(值):判断是否是数字,是返回false不是返回true;   

         函数方法:

    // 无返回值

        <script >         

         test1();

           function  test1(){

         alert('hello word');

    }

          </script>

    //有返回值:

      <script >         

        var ccc =  test1(5,6);

             alert(ccc);

           function  test1(a,b){

       var c =  a+b;

      renturn  c;

    }

          </script>

    JavaScript DOM:

    windows对象:  window.open()     window.close()    window.opener  window.setinterval()/window.setTimeout();     调整页面:  window.navigate("url"); window.moverTo(x,y);   window.resizeTo(wid.hei); window.scrollTo(x,y);

    window.open();

    <input type="button" value="按钮1" id="btn1"/>;

    <script>

            var  oBtn1  =   document.getElementById("btn1");

            oBtn1.onclick = function(){

         window.open("Default2.aspx","_blank","width=400 height=400 left="+((window.screen.width/2)-200)+" top=""+((window.screen.height/2)-200)+");

    //window.screen.width 是屏幕的宽度

    }

      var  oBtn2  =   document.getElementById("btn2");

            oBtn2.onclick = function(){

             a.Close();

    }

     oBtn1.onclick = function(){

        window.scrollTo(0,200);

    }

    //  往下调到200.相当于锚点

    //将父级窗口关闭  widow.opener.close();

    </script>

    window.history 对象:  window.history.back();  window.history.forward();  

    window.history.go(n);   //放正数前进一个页面,放负数后退一个页面;

    window.location对象:  window.location.href="url";    //跳转页面  和window.open();相似;但是浏览器不会屏蔽他,open有的浏览器会屏蔽;  它还会获取当前页面的地址;

    window.document对象:

    {

    获取对象{

    document.getElementById("id")

    document.getElementsByClassName("class")

    document.getElementsByName("name")

    document.getElementsByTagName("标记")

    }

    操作对象属性{

    添加属性:对象.setAttribute("name","value");

    移除属性:对象.removeAttribute("name");

    获取属性值:对象.getAttribute("name");

    }

    操作对象内容{

    对象.innerHTML=“” /对象.innerText ="";

    innerHTML会将里面写的有关的代码编译出来而Text会将你写的内容当做文本展示出来并不会编译。

    普通元素{

    移除内容:对象.innerHTML="" / inner.Text=""

    获取内容:对象.innerHTML

    }

    表单元素{

    移除,获取,添加,都是value;

    }

    }

    操作对象样式

    {

    添加样式,获取:对象.style.width/height/backgroundColor

    移除样式: 对象.style = "";

    实时获取:offsetHeight

    }

    操作相关的样式{

    操作同辈元素{

    上一个,下一个:注意空格和换行

    }

    }

    操作相关的元素;

    创建删除元素;

    事件;

    正则表达式;

    字符串,时间日期,数学函数;

    其他;

    }

  • 相关阅读:
    js全选,全不选,反选练习
    linux查看系统的一些命令,留着用
    JAVA中native方法
    应该被记住的 8 位 Java 人物
    iframe里面的iframe无法左右对齐的解决方法
    sql语句,查找合并后的结果
    地址路径过深时的处理方式
    惠普中国CEO孙振耀退休感言
    js获得readOnly属性
    直接加载错误页面void com.opensymphony.xwork2.ActionSupport.addActionError(String anErrorMessage)
  • 原文地址:https://www.cnblogs.com/yujiamin123/p/7350893.html
Copyright © 2011-2022 走看看