<!-- 在要顯示形象預覽的地方放置以下這句代碼 -->
<div id="bodyshow" style="border:1px solid #000000;padding:0;POSITION: relative; Left: 0px; TOP: 0px; HEIGHT: 226px; WIDTH: 140px;"></div>
<!-- 這是提交表單,把代表使用者形象的字串賦到隱藏欄位 userequip 提交 -->
<form name="equipform" method="post" action="">
<input name="userequip" type="hidden" value="">
<input name="saveequip" type="submit" value="儲存形象" >
<input name="toreequip" type="button" value="原始形象" onclick="shoiwit('df>df>df>0');return false;" >
</form>
<script language="JavaScript">
<!--
var myequip="df>df>df>0"; //最初顯示的配置碼,可由伺服器讀取並輸出。
function shoiwit(equip){ //這個函數由配置碼為參數,顯示虛擬人偶
showlayers=equip.split('>'); //以“>”為分隔字元,分配各層圖片名到一個數組 showlayers[]
str="";
for(i=0;i<showlayers.length;i++){
if(showlayers[i]!='0'&&showlayers[i]!=''){ //如果圖片名為0或空值則該層不顯示。
str+="<img src='http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/"+(i+1)+"/"+showlayers[i]+".gif' style='padding:0;position:absolute;top:0;left:0;width:140;height:226;z-index:"+(i+1)+";'>";
}
}
//最後在最上一層覆蓋一幅完全透明的圖片,這樣使用者在上面右鏈>另存新檔也只能儲存這幅圖了:
str+="<img src='http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/blank.gif' style='padding:0;position:absolute;top:0;left:0;width:140;height:226;z-index:100;'>";
if(equipform.userequip) equipform.userequip.value=myequip=equip; //把配置碼賦值到隱藏欄位中
bodyshow.innerHTML=str; //顯示各層圖片。
}
//頁面載入後先顯示最初的虛擬人偶:
document.body.onload=new Function("shoiwit(myequip)");
function dressit(layer,img){ //這個函數用於更換配置,參數為 層數,圖片名
showlayers=myequip.split('>');
newequip="";
for(i=0;i<showlayers.length;i++){
if(i+1==layer){
if(img==showlayers[i]) newequip+="df"; //如果該層已是這幅圖片,則恢複為原始圖片
else newequip+=img; //否則換為這幅圖
}
else newequip+=showlayers[i]; //其他層圖片不變
if(i+1!=showlayers.length) newequip+=">";
}
shoiwit(newequip); //顯示最新配置
}
-->
</script>
<!--
以下是供選圖片列表,點擊一幅圖則更改相應的層的這幅圖片
注意連結路徑,javascript :dressit(4,1) 表示第4層換上/脫片"1.gif",依此類推;
不過要注意若要第4層換上/脫片“df.gif”,則應加引號,寫成 javascript :dressit(4,'df')
-->
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="84"><a href="javascript :dressit(4,1)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/4/1x.gif" width="84" height="84" border="0"></a></td>
<td width="84"><a href="javascript :dressit(4,2)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/4/2x.gif" width="84" height="84" border="0"></a></td>
<td width="84"><a href="javascript :dressit(4,3)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/4/3x.gif" width="84" height="84" border="0"></a></td>
<td width="84"><a href="javascript :dressit(4,4)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/4/4x.gif" width="84" height="84" border="0"></a></td>
</tr>
<tr>
<td><a href="javascript :dressit(3,1)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/3/1x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(3,2)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/3/2x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(3,3)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/3/3x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(3,4)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/3/4x.gif" width="84" height="84" border="0"></a></td>
</tr>
<tr>
<td><a href="javascript :dressit(2,1)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/2/1x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(2,2)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/2/2x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(2,3)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/2/3x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(2,4)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/2/4x.gif" width="84" height="84" border="0"></a></td>
</tr>
<tr>
<td><a href="javascript :dressit(1,1)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/1/1x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(1,2)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/1/2x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(1,3)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/1/3x.gif" width="84" height="84" border="0"></a></td>
<td><a href="javascript :dressit(1,4)"><img src="http://www.pconline.com.cn/pcedu/redian/code_2003/equipment/1/4x.gif" width="84" height="84" border="0"></a></td>
</tr>
</table>