对联式网页滚动代码

将下面这段脚本放到页面中:

<script language="JavaScript">
<!--

self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
<!-- STALKER CODE -->
function heartBeat() {
 if(IE) {
  diffY = document.body.scrollTop;
  diffX = 0;
 }
 if(NS) {
   diffY = self.pageYOffset; diffX = self.pageXOffset;
 }
 if(diffY != lastScrollY) {
  percent = .1 * (diffY - lastScrollY);
  if(percent > 0) percent = Math.ceil(percent);
  else percent = Math.floor(percent);

  if(IE) document.all.floater.style.pixelTop += percent;
  if(NS) document.floater.top += percent;
  if(IE) document.all.floater1.style.pixelTop += percent;   //这里是右边的对联
  if(NS) document.floater1.top += percent;   //这里是右边的对联
  lastScrollY = lastScrollY + percent;
 }
 if(diffX != lastScrollX) {
  percent = .1 * (diffX - lastScrollX);
  if(percent > 0) percent = Math.ceil(percent);
  else percent = Math.floor(percent);
  if(IE) document.all.floater.style.pixelLeft += percent;
  if(NS) document.floater.top += percent;
  if(IE) document.all.floater1.style.pixelLeft += percent;   //这里是右边的对联
  if(NS) document.floater1.top += percent;   //这里是右边的对联
  lastScrollY = lastScrollY + percent;
 }
}
if(NS || IE) action = window.setInterval("heartBeat()",1);

//-->
</script>

 

下面是显示对联的层,我这里用的是FLASH

<div id="floater" style="position:absolute; left:1px; top:0px; width:97px; height:50px; z-index:1; background-color: #000000; layer-background-color: #000000; border: 1px none #000000;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="110" height="300">
  <param name="movie" value="flash/left.swf">
  <param name="quality" value="high">
  <embed src="flash/left.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="110" height="300"></embed>
</object></div>
<div id="floater1" style="position:absolute; left:893px; top:0px; width:97px; height:50px; z-index:1; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="110" height="300">
    <param name="movie" value="flash/right.swf">
    <param name="quality" value="high">
    <embed src="flash/right.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="110" height="300"></embed>
  </object></div> 

你可能感兴趣的:(JavaScript,object,IE,null,action,border)