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


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

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

<script>
<!-- Beginning of JavaScript -
if (document.all) {
 for (i=0;i<=y_slices-1;i++) {
  for (ii=0;ii<=x_slices-1;ii++) {
      document.write("<div id='span"+spancounter+"' class='spanstyle' border='0'>")
      document.write("</div>")
   spancounter++
  }
 }
}

if (document.layers) {
 document.write("<div id='imgcontainer1' class='spanstyle'>")
 document.write("<a href='#' onMouseOver='scratchnn()'><img src='"+coverimage+"' border='0'></a></div>")
 document.close()
 document.imgcontainer1.left=x_finalpos
 document.imgcontainer1.top=y_finalpos 
}
// - End of JavaScript - -->
</script>


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

<script>
<!-- Beginning of JavaScript -

// The width of your image (pixels)
var imgwidth=230

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

// The name of the coverimage and hidden image.
var coverimage="圖址1"
var hiddenimage="圖址2"

// This block will preload your images. Do not edit this block.
img1=new Image()
img1.src=coverimage
img2=new Image()
img2.src=hiddenimage

// Add an URL to the hidden image
var imgurl=new Array()
urlhiddenimage="http://sheng.phy.nknu.edu.tw/"

// Final horizontal position of the image: distance to the left margin of the window
var x_finalpos=270

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

// Number of sliced cells. A high value will slow down the scratching-effect.
var x_slices=10

// Number of sliced rows. A high value will slow down the scratching-effect.
var y_slices=10

// Do not change the variables below
var xy_slices=x_slices*y_slices
var width_slice=Math.floor(imgwidth/x_slices)
var height_slice=Math.floor(imgheight/y_slices)
var cliptop=0
var clipbottom=height_slice
var clipleft=0
var clipright=width_slice
var spancounter=0

function checkbrowser() {
 if (document.all) {
        initiate()
    }
}

function initiate() {
        spancounter=0
      for (i=0;i<=y_slices-1;i++) {
   for (ii=0;ii<=x_slices-1;ii++) {
    var thisspan=eval("document.all.span"+spancounter+".style")
    thisspan.posLeft=x_finalpos
    thisspan.posTop=y_finalpos
                thisspan.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
    clipleft+=width_slice
          clipright+=width_slice
          spancounter++
   }
         clipleft=0
         clipright=width_slice
         cliptop+=height_slice
         clipbottom+=height_slice
  } 
  for (i=0;i<=xy_slices-1;i++) {
   var thisspan=eval("span"+i)
   thisspan.innerHTML="<a href='#' onMouseOver='scratchimg("+i+")'><img src='"+coverimage+"' border='0'></a>"
  }
}

function scratchimg(thispartofimage) {
  var thisspan=eval("span"+thispartofimage)
  thisspan.innerHTML="<a href='"+urlhiddenimage+"' target='_blank'><img src='"+hiddenimage+"' border='0'></a>"
  
}

function scratchnn() {
 document.imgcontainer1.document.write("<a href='"+urlhiddenimage+"'><img src='"+hiddenimage+"' border='0' target='_blank'></a>") 
 document.imgcontainer1.document.close() 
}

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

<style>
.spanstyle {
 position:absolute;
    left:-5000px;
}
</style>


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

 onLoad="checkbrowser()"

arrow
arrow
    全站熱搜

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