在html中怎样实现当鼠标放到submit按钮上时使鼠标变为单击文字链接时的图标(即手的形状)?

html-css013

在html中怎样实现当鼠标放到submit按钮上时使鼠标变为单击文字链接时的图标(即手的形状)?,第1张

在html文件中添加一个事件,就是当鼠标滑动到submit按钮上时,设置鼠标样式即可,具体例子如下:

<html>

<body>

<p>请把鼠标移动到单词上,可以看到鼠标指针发生变化:</p>

<span style="cursor:auto">

Default</span><br />

<span style="cursor:pointer">

Pointer</span><br />            <!--这个就是你需要的-->

<span style="cursor:move">

Move</span><br />

<span style="cursor:e-resize">

e-resize</span><br />

<span style="cursor:ne-resize">

ne-resize</span><br />

<span style="cursor:nw-resize">

nw-resize</span><br />

<span style="cursor:text">

text</span><br />

<span style="cursor:wait">

wait</span><br />

<span style="cursor:help">

help</span>

</body>

</html>

鼠标上变化的文字

脚本说明:

把如下代码加入<body>区域中

<SCRIPT language="JavaScript1.2">

<!--

var scroller_msg='Hi,网络编程站欢迎你的光临!'

var dismissafter=0

var initialvisible=0

if (document.all)

document.write('<marquee id="curscroll" style="position:absolutewidth:150pxborder:1px solid blackfont-size:14pxbackground-color:whitevisibility:hidden">'+scroller_msg+'</marquee>')

function followcursor(){

//move cursor function for IE

if (initialvisible==0){

curscroll.style.visibility="visible"

initialvisible=1

}

curscroll.style.left=document.body.scrollLeft+event.clientX+10

curscroll.style.top=document.body.scrollTop+event.clientY+10

}

function dismissmessage(){

curscroll.style.visibility="hidden"

}

if (document.all){

document.onmousemove=followcursor

document.ondblclick=dismissmessage

if (dismissafter!=0)

setTimeout("dismissmessage()",dismissafter*1000)

}

//-->

</SCRIPT>

================================

鼠标箭头效果

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var x, y, xold, yold, xdiff, ydiff

var dir = Array()

dir[0] = "n-resize"

dir[1]="ne-resize"

dir[2]="e-resize"

dir[3]="se-resize"

dir[4] = "s-resize"

dir[5]="sw-resize"

dir[6]="w-resize"

dir[7]="nw-resize"

document.onmousemove = FindXY

function display(direction) {

document.body.style.cursor = dir[direction]

}

function FindXY(loc) {

x = (document.layers) ? loc.pageX : event.clientX

y = (document.layers) ? loc.pageY : event.clientY

xdiff = x - xold

ydiff = y - yold

if ((xdiff < 2) &&(ydiff <-2)) display(0)

if ((xdiff < 2) &&(ydiff > 2)) display(4)

if ((xdiff > 2) &&(ydiff < 2)) display(2)

if ((xdiff <-2) &&(ydiff < 2)) display(6)

if ((xdiff > 2) &&(ydiff > 2)) display(3)

if ((xdiff > 2) &&(ydiff <-2)) display(1)

if ((xdiff <-2) &&(ydiff > 2)) display(5)

if ((xdiff <-2) &&(ydiff <-2)) display(7)

xold = x

yold = y

}

// End -->

</script>