小实例 敲击键盘是返回键盘上的unicode码 获取鼠标当前的坐标值
2012-02-27 19:21
435 查看
<!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>
<script language="javascript" type="text/javascript">
function whichButton(event){
alert(event.keyCode);
}
</script>
</head>
<body onkeyup="whichButton(event)">
<p><b>注释:</b>在测试这个例子时,要确保右侧的框架获得了焦点。</p>
<p>在键盘上按一个键。消息框会提示出按键的unicode。</p>
</body>
</html>
//获取鼠标当前的坐标值
<html>
<head>
<script type="text/javascript">
function show_coords(event)
{
x=event.clientX
y=event.clientY
alert("X 坐标: " + x + ", Y 坐标: " + y)
}
</script>
</head>
<body onmousedown="show_coords(event)">
<p>请在文档中点击。一个消息框会提示出鼠标指针的 x 和 y 坐标。</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function whichButton(event){
alert(event.keyCode);
}
</script>
</head>
<body onkeyup="whichButton(event)">
<p><b>注释:</b>在测试这个例子时,要确保右侧的框架获得了焦点。</p>
<p>在键盘上按一个键。消息框会提示出按键的unicode。</p>
</body>
</html>
//获取鼠标当前的坐标值
<html>
<head>
<script type="text/javascript">
function show_coords(event)
{
x=event.clientX
y=event.clientY
alert("X 坐标: " + x + ", Y 坐标: " + y)
}
</script>
</head>
<body onmousedown="show_coords(event)">
<p>请在文档中点击。一个消息框会提示出鼠标指针的 x 和 y 坐标。</p>
</body>
</html>
相关文章推荐
- javascript中获取当前鼠标的坐标
- delphi 获取鼠标当前位置的相对坐标
- JS获取鼠标坐标的实例方法
- jQuery获取当前鼠标相对位置坐标和点击图片跳转上一张或下一张功能
- JS获取鼠标坐标的实例方法
- js与jquery中获取当前鼠标的x、y坐标位置的代码
- js与jquery中获取当前鼠标的x、y坐标位置的代码
- 解决C#获取鼠标相对当前窗口坐标的实现方法
- Python2.7: 使用Pyhook模块监听鼠标键盘事件-获取坐标
- js 获取坐标 通过JS得到当前焦点(鼠标)的坐标属性
- VC 获取鼠标当前位置坐标和RGB
- JS获取鼠标坐标位置实例分析
- 【实例】【html5】在canvas获取鼠标的坐标
- 获取当前鼠标所在的坐标
- IOS开发实例-获取用户当前地理坐标
- 获取当前鼠标的坐标
- delphi 获取鼠标当前位置的相对坐标
- Winform WebBrowser 获取鼠标当前坐标
- js 获取坐标 通过JS得到当前焦点(鼠标)的坐标属性
- [js高手之路] html5 canvas动画教程 - 实时获取鼠标的当前坐标