語法展示::  http://home.graffiti.net/tgaajfd/


請用IE6.0或更新版本觀看語法特效展示

將以下程式碼複製,貼在<body>及</body>標籤之間。

 

<script>
<!-- Beginning of JavaScript -
for (i=0;i<=imgslices-1;i+=2) {
 marginright=document.body.clientWidth+50
    document.write("<span id='span"+i+"' style='position:absolute;visibility:visible; left:"+marginright+"px;top:"+y_finalpos+"px;clip:rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)'>")
 document.write("<img src='"+imgurl+"'>")
    document.write("</span>")
 cliptop+=2*height_slice
 clipbottom+=2*height_slice
}
 cliptop=height_slice
 clipbottom=2*height_slice

for (i=1;i<=imgslices-1;i+=2) {
 marginleft=-imgwidth-50
    document.write("<span id='span"+i+"' style='position:absolute;visibility:visible; left:"+marginleft+"px;top:"+y_finalpos+"px;clip:rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)'>")
 document.write("<img src='"+imgurl+"'>")
    document.write("</span>")
 cliptop+=2*height_slice
 clipbottom+=2*height_slice
}
// - End of JavaScript - -->
</script>


將以下程式碼複製,貼在<head>及</head>標籤之間。


<script>
<!-- Beginning of JavaScript -
  
// The width of your image (pixels)
var imgwidth=235

// The height of your image (pixels)
var imgheight=180

// The URL of the sliced image
var imgurl="圖址"

// Final horizontal position of the image: distance to the left margin of the window (pixels)
// IMPORTANT:
// if you want to center the image in the middle of the browser-window then write -1.
// If you want to put the image on a absolute position
// then write the number (for instance 223).
var x_finalpos=268

// Final vertical position of the image: distance to the top margin of the window
var y_finalpos=220

// Total number of slices
var imgslices=20

// Speed of horizontal gliding
var step=10
var pause=5

// Do not edit the variables below this line
var x_rightspans=0
var x_leftspans=0
var marginright
var marginleft
var height_slice=Math.floor(imgheight/imgslices)
var cliptop=0
var clipbottom=cliptop+height_slice
var clipleft=0
var clipright=imgwidth
var spannummer=0
var spannrbefore=0

function initiate() {
 if (x_finalpos==-1) {
  x_finalpos=Math.floor(document.body.clientWidth/2)-Math.floor(imgwidth/2)
 }
 if (document.all) {
  moveslices_IE()
 }
}

function moveslices_IE() {
if (x_rightspans==0 || x_leftspans==0) {
 if (x_rightspans==0) {
  for (i=0;i<=imgslices-1;i+=2) {
   var thisspan=eval("document.all.span"+i+".style")
   thisspan.posLeft-=step
  }
  if (thisspan.posLeft<=x_finalpos) {
   x_rightspans=1
   for (i=0;i<=imgslices-1;i+=2) {
    var thisspan=eval("document.all.span"+i+".style")
    thisspan.posLeft=x_finalpos
   }
  }
 }
 if (x_leftspans==0) {
  for (i=1;i<=imgslices-1;i+=2) {
   var thisspan=eval("document.all.span"+i+".style")
   thisspan.posLeft+=step
  }
  if (thisspan.posLeft>=x_finalpos) {
   x_leftspans=1
   for (i=1;i<=imgslices-1;i+=2) {
    var thisspan=eval("document.all.span"+i+".style")
    thisspan.posLeft=x_finalpos
   }
  }
 }
 var timer=setTimeout("moveslices_IE()",pause)
}
 else {
  clearTimeout(timer)
 }
}

// - End of JavaScript - -->
</script>


將以下程式碼複製,貼在<body >標籤裡面。

 onLoad="initiate()"

創作者介紹
創作者 uuiop6623 的頭像
uuiop6623

uuiop

uuiop6623 發表在 痞客邦 留言(0) 人氣()