您的位置:首页 > 其它

小实例 敲击键盘是返回键盘上的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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: