DOM中对象的属性

event.button为1为左键,2为右键,3为左右键按同事按(IE浏览器好像不行,火狐的可以)
<body οnmοusedοwn="if(event.button == 2){alert('禁止复制')}">


<input type="button" value="当前页面地址" οnclick="alert(location.href)" />

<input type="button" value="重定向地址" οnclick="location.href='8.html'" /> 和navigate方法效果一样

window.location.reload() 刷新当前页面

<input type="button" value="点击" οnclick="if(window.event.ctrlKey){alert('按下了Ctrl')}else{alert('普通点击')}" />
IE浏览器可以,火狐的不行

window.event 用来获取发生时间时的信息,时间不局限于window对象的事件,所有的元素时间都可以
通过event属性去到相关信息

window.event中的clientX clientY发生时间时鼠标在客户区的坐标
screenX screenY发生时间时鼠标在屏幕上的坐标
offsetX  offsetY发生时间时鼠标相对于事件源(比如点击按钮时出发的onclick)的坐标

returmValue事件,如果将returnValue设置为false,就会取消默认时间的处理,比如禁止超链接的onclick里面禁止访问href的页面,在表单校验时禁止提交表单到服务器(本人测试,在IE下可以正常使用,火狐下不行不能执行window.event.returnValue=false;,即禁止跳转到百度页面)
<a href="http://www.baidu.com" οnclick="alert('禁止访问');window.event.returnValue=false;">百度</a>

 

 

------------------------------------------------全部代码--------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>演示文档 -当前页面地址</title>
</head>
<body οnmοusedοwn="if(event.button == 2){alert('禁止复制')}">
<input type="button" value="当前页面地址" οnclick="alert(location.href)" />
<input type="button" value="重定向地址" οnclick="location.href='8.html'" />
<input type="button" value="点击" οnclick="if(window.event.ctrlKey){alert('按下了Ctrl')}else{alert('普通点击')}" />
<a href="http://www.baidu.com" οnclick="alert('禁止访问');window.event.returnValue=false;">百度</a>


</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值