北京科创讯通:求在一个网页中加入鼠标图片的代码.

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 15:14:40
请各位高手帮助一下,现在本人没有积分,不然一定会悬赏的.

<style type="text/css">
body{
cursor:url(/images/youMouse.ani);
}
</style>

你是指改变鼠标指针吗?可以用CSS实现。

改变整页的鼠标指针:
<style type="text/css">
body {
cursor:normal; /*使用系统默认指针,就是箭头*/

cursor:url(mouse1.cur); /*使用你自己提供是静态指针*/

cursor:url(mouse2.ani); /*使用你自己提供是动画指针*/

</style>

改变链接指针:把上述的body改为a即可。

单独为某个对象添加特殊指针只要为该对象添加style样式即可:
<style="cursor:normal; 或cursor:url(mouse1.cur); 或cursor:url(mouse2.ani); ">

<html>
<title>跟随鼠标的十字线</title>
<head>
<meta name="keywords" content="51windows.Net">
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body>
<script language="JavaScript">
<!--
var jsstr = ""
+ "<img src=\"about:blank\" id=\"leftright\" style=\"width:expression(document.body.clientWidth);height:1px;position:absolute;left:0;top:0;background-color:#6699cc;z-index:100;\" \/>\n"
+ "<img src=\"about:blank\" id=\"topdown\" style=\"height:expression(document.body.clientHeight);width:1px;position:absolute;left:0;top:0;background-color:#6699cc;z-index:100;\" \/>\n"
document.writeln(jsstr);

function followmouse(){
leftright.style.top = window.event.y-2
topdown.style.left = window.event.x-2
}
document.onmousemove=followmouse
//-->
</script>
</body>
</html>

这个代码更有意思