事件类型,

1.select 当选择输入框字符时候触发 火狐不支持

input.onselect = function () {
      console.log(window.getSelection().toString(), '我被触发了');
    }

2. onresize当页面发生缩放时候触发

window.onresize = function(){
      console.log(window.outerWidth,window.outerHeight)
    }

3.滚动事件 scroll

window.onscroll = function () {
      // console.log(window.pageYOffset,'获取距离上方位置')
      console.log(document.documentElement.scrollTop, '获取距离上方位置')
    }

4.监听输入框值事件 input

input.oninput = function () {
      console.log(event.target.value, '输入框输入的值')
    }

5. 聚焦事件 focus

input.onfocus = function () {
      this.style.backgroundColor = 'red'
    }

6.失焦事件 blur

input.onblur = function () {
      // this.style.backgroundColor = 'blue';
    }

7.鼠标事件

     * mouseenter 鼠标移入

     * mouseleave 鼠标移除

     * mousemove  鼠标一直移动

     * mousedown

     * mouseup

     * mousewheel

     * click

     * dbclick

8.键盘事件

     * keydown 键盘按下事件

     * keyup   键盘抬起事件

     * keypress 键盘持续按下事件

9.打开一个链接  一个页面

w =  window.open('https://baidu.com','_blank','width=600px,height=600px');
     console.log(w,'窗口对象');
      // 控制新窗口打开宽高 
     w.resizeTo(400,400);
    //  控制窗口打开位置 x y 
     w.moveTo(200,200);
    }
    btn2.onclick = function(){
      // 关闭窗口
      w.close();
      
    }

10.对话框

弹框

    alert('我是一个弹框');

 确认框

    var res = confirm('您确定吗');//返回值true或者false

    console.log(res);

提示框

    var res = prompt('请输入您的姓名');

    console.log(res);

11.location

assign()

传递一个url参数,打开新url,并在浏览记录中生成一条记录。

replace()

参数为一个url,结果会导致浏览器位置改变,但不会在历史记录中生成新记录。

reload()

重新加载当前显示的页面,参数可以为boolean类型,默认为false

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值