• DOM


    alert 是浏览器的对象,而不是javascript的对象,双引号里面要用单引号

    <html>
    <head></head>
    <body onmousedown="alert('hello');alert('haha')">
    <p>dfdfd</p>
    </body>
    </html>

     动态关联事件

    function f1(){
    alert("f1");
    }
    <input type="button" value="按钮" onclick="document.ondblclick=f1"></input>

    鼠标事件

    onclick(单击)
    ondblclick(双击)
    onkeydown(按键按下)
    onkeypress(点击按键)
    onkeyup(按键释放)
    onmousedown(鼠标按下)
    onmousemove(鼠标移动)
    onmouseout(鼠标离开元素范围)
    onmouseover(鼠标移动到元素范围)
    onmouseepu(鼠标按键释放)
    var f1 = function(){
        if(confirm("是否进入")){
            alert("进入了");
        }
        else{
            alert("取消进入");
        }
    }
    var f2 = function(){
        //navigate只支持IE
        navigate("http://www.baidu.com");
    }
    var f3 = function(){
        var interval1 = setInterval("alert('hello')",2000);
    }
    var f4 = function(){
        clearInterval(interval1);
    }
    var f5 = function(){
        //只执行一次
        setTimeout("alert('hello')",2000);
    }

    走马灯效果

    var scroll = function(){
        var title = document.title;
        var firstch = title.charAt(0);
        var leftstr = title.substring(1,title.length);
        document.title = leftstr+firstch;
    }
    setInterval(scroll,500);

    取当前页面的地址

    window.location.href

    改变当前页面的地址

    window.location.href="http://www.baidu.com";

    刷新页面

    window.location.reload();

    window.event事件

    var f1 = function(event){
         if(event.ctrlKey){
        alert("按下了Ctrl");
         }
         else{
         alert("普通点击");
         }
    }
    <input type="button" value="点击" onclick="f1(event)"></input>

    挡截事件,禁止访问

    <a href="http://www.baidu.com" onclick="alert('禁止访问');window.event.returnValue=false" >百度</a>
  • 相关阅读:
    常用查看日志的命令
    通过maven profile配置不同开发环境
    java使用shiro小记
    gitlab使用小记
    java使用guava变形数据结构
    php 把驼峰样式的字符串转换成下划线样式的字符串
    tcp粘包和拆包的处理方案
    php和js中,utf-8编码转成base64编码
    yum的用法
    rpm的用法
  • 原文地址:https://www.cnblogs.com/cppwen/p/3072549.html
Copyright © 2020-2023  润新知