zoukankan      html  css  js  c++  java
  • js基本知识点回顾

      JavaScript:  基本语法:  与c#语法基本一致,类型转换:var a= parseint(值): var b = parsefloat(值);  

            isNaN(值):判断是否是数字,是返回false不是返回true;   

         函数方法:

    //有返回值:
      <script >         
        var ccc =  test1(5,6);
             alert(ccc);
           function  test1(a,b){
       var c =  a+b;
    
      renturn  c;
    }
      </script>
    // 无返回值
        <script >         
         test1();
           function  test1(){
    
         alert('hello word');
    }
          </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对象:

    获取对象:

    <script>
        document.getElementById("id")
    
        document.getElementsByClassName("class")
    
        document.getElementsByName("name")
    
        document.getElementsByTagName("标记")
    </script>

    操作对象属性:

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

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

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

    操作对象内容:

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

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

    普通元素:

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

    获取内容:对象.innerHTML

  • 相关阅读:
    应用市场高速下载以及网页端调起APP页面研究与实现
    linux系统下,添加硬盘并挂载到操作系统的shell 脚本范例
    linux系统下,新加硬盘并把现有的/home目录扩容。
    Java打印裴波那契数列
    JAVA排序的方法
    Java语言输出菱形图型
    Oracle中的sql脚本语言中的循环语句介绍
    Oracle存储过程的创建实例和调用实例
    数组常用方法3---新增元素
    数组常用方法2——修改数组元素。
  • 原文地址:https://www.cnblogs.com/liuyubin0629/p/7351830.html
Copyright © 2011-2022 走看看