8-6.htm

来自「JScript网页特效,包含很多的实现网页特效的方法.」· HTM 代码 · 共 68 行

HTM
68
字号
<html>
<head>
<title>§8.6 在网页中随鼠标移动的瞄准器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE type=text/css>
.hair {BACKGROUND-COLOR: red; FONT-SIZE: 1px; HEIGHT: 1px; LEFT: 0px; POSITION: absolute; TOP: 0px; WIDTH: 1px; layer-background-color: red}
</STYLE>
</head>

<body bgcolor="#FFFFFF" text="#000000">

<DIV class=hair id=xhair></DIV>
<DIV class=hair id=yhair></DIV>

<script language=javascript>
var isNS=(navigator.appName=="Netscape");
var _all=(isNS)? '' : 'all.' ;
var _style=(isNS)? '' : '.style' ;
var _visible=(isNS)? 'show' : 'visible';
var xhair=eval('document.'+_all+'xhair'+_style);
var yhair=eval('document.'+_all+'yhair'+_style);

function resize()
{
  if(isNS)
  {
    xhair.clip.width=window.innerWidth;
    xhair.clip.height=1;
    yhair.clip.width=1;
    yhair.clip.height=window.innerHeight;
  }
  else
    {
      xhair.width=document.body.clientWidth;
      yhair.height=document.body.clientHeight;
    }
}

function movehair(evnt)
{
  if(isNS)
  {
    xhair.moveTo(pageXOffset,evnt.pageY);
    yhair.moveTo(evnt.pageX,pageYOffset);
  }
  else
  {
    xhair.pixelTop=event.clientY+document.body.scrollTop;
    xhair.pixelLeft=document.body.scrollLeft;
    yhair.pixelLeft=event.clientX+document.body.scrollLeft;
    yhair.pixelTop=document.body.scrollTop;
  }
  return false;
}

function reloadNS()
{
  setTimeout('window.location.reload()', 500);
}

window.onresize=(isNS)? reloadNS : window.onresize=resize;
if(isNS) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=movehair;
window.onload=resize;
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?