中文(繁体)
<!-- 將下列程式碼加到<body>區域中--> <script language="JavaScript"> <!-- //該函數在呼叫過程中只需要在將要點擊的單元格內的onclick事件中呼叫showme函數即可//function showme(obj1, obj2)此函數主要為使點擊的物件高亮度顯示,並呼叫moveme函數,參數obj1為母體即<div>標籤的id,obj2為點擊物件本身// function moveme(obj)此函數判斷單元的移動,並呼叫對應的函數處理,obj參數為母體//function moveup(obj,objtop)此函數使一個單元向上移動,參數obj為母體,objtop為母體的本身最高高度//function movedown(obj,objbuttom)此函數使一個單元向下移動,參數obj為母體,objbuttom為母體的本身最低高度var headHeight = 22;//每個標題的高度var bodyHeight = 160;/ /母體高度var objcount = 6;//項目的個數,要改變了項目的個數別忘了該這個東西var step = 6;//移動速度(請確認可以被'bodyHeight-headHeight'整除,當前設定可選速度為1,2,3,6,23,138) var moving = false;//是否有移動的項目function showme(obj1, obj2) { //以下循環為改變標題的背景顏色if (moving ) return; moving = true; for(i=0;i<document.all.tags("td").length;i++) if (document.all.tags("td")[i].className.indexOf( 'headtd') == 0) document.all.tags("td")[i].className = 'headtd1'; obj2.className = 'headtd2'; moveme(obj1); } function moveme(obj) { idnumber = parseInt(obj.id.substr(4)); objtop = headHeight * (idnumber - 1); objbuttom = bodyHeight + headHeight * (idnumber - 2); currenttop = parseInt(obj.style.top); if (currenttop >= objbuttom) { //檢驗出每一個應該向上移動的層countid = 1; for(i=0;i<document.all.tags("div").length;i++) if (document.all.tags(" div")[i].id == 'item'+countid+'body') { obj = document.all.tags("div")[i]; objtop = headHeight * (countid - 1); if (countid = = idnumber) { moveup(obj,objtop,false); break; } else moveup(obj,objtop,true); countid++; } } else if ((currenttop <= objtop) && (idnumber < objcount)) { //檢定出每一個應該向下移動的層idnumber++; countid = objcount; for(i=document.all.tags("div").length-1;i>=0;i--) if (document.all.tags ("div")[i].id == 'item'+countid+'body') { obj = document.all.tags("div")[i]; objbuttom = bodyHeight + headHeight * (countid - 2); if (countid == idnumber) { movedown(obj,objbuttom,false); break; } else movedown(obj,objbuttom,true); countid--; } } } function moveup(obj,objtop,ismove) { currenttop = parseInt 讓(obj.style.top); if (currenttop > objtop) { obj.style.top = currenttop - step; setTimeout('moveup('+obj.id+','+objtop+','+ismove+')',1 ) return; }<center> <script language="javascript"> function preview() { bdhtml=window.document.body.innerHTML; sprnstr="<!--startprint-->"; eprnstr="<!-- endprint-->"; prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); window.document.body.innerHTML=prnhtml; window. print(); //prnform.htext.value=prnhtml; //prnform.submit(); //alert(prnhtml); } </script> 這些內容是不會被印出來的<br> +++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++ <center>本部分以上不被列印</center> <!--startprint--> <table width="70%" align="center" bgcolor="#0000FF" cellpadding="2" cellspacing="1"> <tr bgcolor="#6699FF"> <td> <div align="center">標題一</div> </td> <td> <div align="center ">標題二</div> </td> <td> <div align="center">標題三</div></td> <td> <div align="center">標題四</div> </td> </tr> <tr bgcolor="#6699FF"> <td> </td> <td> </td> <td> </td> <td> </td> </tr> < /table> <!--endprint--> +++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++<br> 這些內容是不會已印製的<div align="center"> <input type="button" name="print" value="預覽並列印" onclick="preview()"> </div> </center>