• location.href 和document.referrer、event.keyCode、setTimeout 与setInterval、前置与后置型递增递减操作符


    1、window.location.href 与 document.referrer

    window.location.href 设置或返回完整的URL

    location.hash 设置或返回#后面的URL(锚点)

    document.referrer 属性可返回载入当前文档的文档的URL,即前一个页面。如果当前文档不是通过超级链接访问的 则为null。

    2、event.keyCode

    当用户按下一个键盘按键时,发生onkeydown事件。

    IE浏览器使用event.keyCode取回被按下的字符。Netscape/Firefox/Opera使用event.which

    列一下常用的keyCode值

    keycode  8   =  BackSpace BackSpace 
    keycode  9   =  Tab Tab 
    keycode  12  =  Clear 
    keycode  13  =  Enter
    keycode  20  =  Caps Lock
    keycode  27  =  Escape
    keycode  32  =  Space
    keycode  34  =  Next
    keycode  35  =  End
    keycode  36  =  Home
    keycode  37  =  Left
    keycode  38  =  Up
    keycode  39  =  Right
    keycode  40  =  Down
    keycode  46  =  Delet

    更详细的请event.keycode大全 http://www.cnblogs.com/DareOnly/archive/2009/02/26/1398928.html

    3、setTimeout  setInterval

     setTimeout(code,millisec) 在指定的毫秒数之后调用函数或计算表达式

    setTimeout(“alert('hello~')”,3000);   //3秒之后弹出框

    setTimeout只执行一次,clearTimeout(id_of_settimeout)方法可以取消setTimeOut设置的timeout,id_of_settimeout为setTimeOut的返回值。

    setInterval(code,millisec)  按照指定的周期来调用函数或计算表达式

    setTimeOut(“alert('hello~')”,3000);   //每三秒弹出一次 

    setInterval方法会不停地调用函数或表达式,直到clearInterval(id_of_setinterval)方法被调用或者关闭窗口,id_of_setinterval为setInterval的返回值

    4、递增和递减操作符

    前置型 操作符位于要操作的变量之前,变量的值都是在语句被求值之前改变的。

    后置型 操作符位于要操作的变量之后,变量的值都是在语句被求值之后改变的。

    var a = 0;
    var b = ++a +10;
    alert(a);          //1
    alert(b);         //11
    var a = 0;
    var b = a++ + 10;
    alert(a);        //1
    alert(b);        //10
  • 相关阅读:
    C#时间格式转换问题(12小时制和24小时制)
    ajax跨域请求webservice webconfig配置
    C#时间戳转化为DateTime
    C#生成缩略图
    codeforces-1348-C Phoenix and Distribution
    P4314 CPU监控
    YangK's dfs序与树链剖分
    Yangk's 静态主席树
    P2253 好一个一中腰鼓!
    codeforces-1341D-Nastya and Scoreboard 记忆化搜索
  • 原文地址:https://www.cnblogs.com/blackwood/p/2663200.html
Copyright © 2020-2023  润新知