CSDN博客

img yanweidong1030

QQShow?你也可以做!

发表于2004/7/6 23:34:00  1273人阅读

<!-- 在要显示形象预览的地方放置以下这句代码 -->
<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>

0 0

相关博文

我的热门文章

img
取 消
img