龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

详解JS中event使用方法(1)(3)

时间:2013-03-06 14:58来源:未知 作者:admin 点击:
分享到:
11.propertyName 描述: 设置或返回元素的变化了的属性的名称。 语法: event.propertyName[=sProperty] 可能的值: sProperty是一个字符串,指定或返回触发事件的元素

11.propertyName

描述:
设置或返回元素的变化了的属性的名称。

语法:
event.propertyName[=sProperty]

可能的值:
sProperty是一个字符串,指定或返回触发事件的元素在事件中变化了的属性的名称。
这个属性是可读写的。无默认值。

注释:
你可以通过使用onpropertychange事件,得到propertyName的值。

例子:
下面的例子通过使用onpropertychange事件,弹出一个对话框,显示propertyName的值。 

  1. <HEAD> 
  2. <SCRIPT>...  
  3. functionchangeProp()...{  
  4. btnProp.value="ThisisthenewVALUE";  
  5. }  
  6.  
  7. functionchangeCSSProp()...{  
  8. btnStyleProp.style.backgroundColor="aqua";  
  9. }  
  10. </SCRIPT> 
  11. </HEAD> 
  12. <BODY> 
  13. <P>TheeventobjectpropertypropertyNameis  
  14. usedheretoreturnwhichpropertyhasbeen  
  15. altered.</P> 
  16.  
  17. <INPUTTYPEINPUTTYPE=buttonID=btnProponclick="changeProp()" 
  18. VALUE="ClicktochangetheVALUEpropertyofthisbutton" 
  19. onpropertychange='alert(event.propertyName+"propertyhaschangedvalue")'> 
  20. <INPUTTYPEINPUTTYPE=buttonID=btnStyleProp  
  21. onclick="changeCSSProp()" 
  22. VALUE="ClicktochangetheCSSbackgroundColorpropertyofthisbutton" 
  23. onpropertychange='alert(event.propertyName+"propertyhaschangedvalue")'> 
  24. </BODY> 
  25.  

12.returnValue

描述:
设置或检查从事件中返回的值

语法:
event.returnValue[=Boolean]

可能的值:
true事件中的值被返回
false源对象上事件的默认操作被取消

例子见本文的开头。

13.screenX

描述:
检测鼠标相对于用户屏幕的水平位置

语法:
event.screenX

注释:
这是个只读属性。这意味着,你只能通过它来得到鼠标的当前位置,却不能用它来更改鼠标的位置。

14.screenY

描述:
检测鼠标相对于用户屏幕的垂直位置

语法:
event.screenY

注释:
这是个只读属性。这意味着,你只能通过它来得到鼠标的当前位置,却不能用它来更改鼠标的位置。

15.shiftKey

描述:
检查shift键的状态。

语法:
event.shiftKey

可能的值:
当shift键按下时,值为TRUE,否则为FALSE。只读。

精彩图集

赞助商链接