我做的是一个图片切换,上面一个大图,下面一排小图 <div id="tbody">
<div id="mainbody">
<table id="detail_table">
<tr>
<td valign="middle" align="center">
<img src='../<%=p.ShowImg %>' rel='../<%=p.ShowImg %>' alt='<%=p.Name%>' id="mainphoto"
name='../<%=p.ShowImg %>' height="240" width="318" onload="DrawImage(this);" />
</td>
</tr>
</table>
</div>
<img src="../images/goleft.gif" alt="上一张" height="50" id="goleft" />
<img src="../images/goright.gif" alt="下一张" height="50" id="goright" />
<div id="photos">
<div id="showArea">
<%
string url = p.ImgUrl;
string[] sArray = url.Split('|');
foreach (string path in sArray)
{
%>
<a href='../<%=path %>'>
<img src='../<%=path %>' rel='../<%=path %>' name='../<%=path %>' alt='<%=p.Name%>'
width="55" /></a>
<%} %>
</div>
</div> <script language="javascript" type="text/javascript">
var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1; //速度,越大越慢
var spec = 1; //每次滚动的间距, 越大滚动越快
var minOpa = 100; //滤镜最小值
var maxOpa = 200; //滤镜最大值
var spa = 2; //缩略图区域补充数值
var w = 0;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*20);
function $$(e) {return document.getElementById(e);}
function goleft() {$$('photos').scrollLeft -= spec;}
function goright() {$$('photos').scrollLeft += spec;}
function setOpacity(e, n) {
if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
else e.style.opacity = n/100;
}
$$('goleft').style.cursor = 'pointer';
$$('goright').style.cursor = 'pointer';
$$('mainphoto').onmouseover = function() {setOpacity(this, maxOpa);}
$$('mainphoto').onmouseout = function() {setOpacity(this, minOpa);}
$$('mainphoto').onclick = function() {location = this.getAttribute('name');}
$$('goleft').onmouseover = function() {this.src = '../images/goleft2.gif'; MyMar=setInterval(goleft, speed);}
$$('goleft').onmouseout = function() {this.src = '../images/goleft.gif'; clearInterval(MyMar);}
$$('goright').onmouseover = function() {this.src = '../images/goright2.gif'; MyMar=setInterval(goright,speed);}
$$('goright').onmouseout = function() {this.src = '../images/goright.gif'; clearInterval(MyMar);}
window.onload = function() {
setOpacity($$('mainphoto'), minOpa);
var rHtml = '';
var p = $$('showArea').getElementsByTagName('img');
for (var i=0; i<p.length; i++) {
w += parseInt(p[i].getAttribute('width')) + spa;
setOpacity(p[i], minOpa);
p[i].onclick = function() {location = this.getAttribute('name');}
p[i].onmouseover = function() {
setOpacity(this, maxOpa);
$$('mainphoto').src = this.getAttribute('rel');
$$('mainphoto').setAttribute('name', this.getAttribute('name'));
setOpacity($$('mainphoto'), maxOpa);
}
p[i].onmouseout = function() {
setOpacity(this, minOpa);
setOpacity($$('mainphoto'), minOpa);
}
rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" />';
}
$$('showArea').style.width = parseInt(w) + 'px';
var rLoad = document.createElement("div");
$$('photos').appendChild(rLoad);
rLoad.style.width = "1px";
rLoad.style.height = "1px";
rLoad.style.overflow = "hidden";
rLoad.innerHTML = rHtml;
}
</script> </div>
<div id="mainbody">
<table id="detail_table">
<tr>
<td valign="middle" align="center">
<img src='../<%=p.ShowImg %>' rel='../<%=p.ShowImg %>' alt='<%=p.Name%>' id="mainphoto"
name='../<%=p.ShowImg %>' height="240" width="318" onload="DrawImage(this);" />
</td>
</tr>
</table>
</div>
<img src="../images/goleft.gif" alt="上一张" height="50" id="goleft" />
<img src="../images/goright.gif" alt="下一张" height="50" id="goright" />
<div id="photos">
<div id="showArea">
<%
string url = p.ImgUrl;
string[] sArray = url.Split('|');
foreach (string path in sArray)
{
%>
<a href='../<%=path %>'>
<img src='../<%=path %>' rel='../<%=path %>' name='../<%=path %>' alt='<%=p.Name%>'
width="55" /></a>
<%} %>
</div>
</div> <script language="javascript" type="text/javascript">
var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1; //速度,越大越慢
var spec = 1; //每次滚动的间距, 越大滚动越快
var minOpa = 100; //滤镜最小值
var maxOpa = 200; //滤镜最大值
var spa = 2; //缩略图区域补充数值
var w = 0;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*20);
function $$(e) {return document.getElementById(e);}
function goleft() {$$('photos').scrollLeft -= spec;}
function goright() {$$('photos').scrollLeft += spec;}
function setOpacity(e, n) {
if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
else e.style.opacity = n/100;
}
$$('goleft').style.cursor = 'pointer';
$$('goright').style.cursor = 'pointer';
$$('mainphoto').onmouseover = function() {setOpacity(this, maxOpa);}
$$('mainphoto').onmouseout = function() {setOpacity(this, minOpa);}
$$('mainphoto').onclick = function() {location = this.getAttribute('name');}
$$('goleft').onmouseover = function() {this.src = '../images/goleft2.gif'; MyMar=setInterval(goleft, speed);}
$$('goleft').onmouseout = function() {this.src = '../images/goleft.gif'; clearInterval(MyMar);}
$$('goright').onmouseover = function() {this.src = '../images/goright2.gif'; MyMar=setInterval(goright,speed);}
$$('goright').onmouseout = function() {this.src = '../images/goright.gif'; clearInterval(MyMar);}
window.onload = function() {
setOpacity($$('mainphoto'), minOpa);
var rHtml = '';
var p = $$('showArea').getElementsByTagName('img');
for (var i=0; i<p.length; i++) {
w += parseInt(p[i].getAttribute('width')) + spa;
setOpacity(p[i], minOpa);
p[i].onclick = function() {location = this.getAttribute('name');}
p[i].onmouseover = function() {
setOpacity(this, maxOpa);
$$('mainphoto').src = this.getAttribute('rel');
$$('mainphoto').setAttribute('name', this.getAttribute('name'));
setOpacity($$('mainphoto'), maxOpa);
}
p[i].onmouseout = function() {
setOpacity(this, minOpa);
setOpacity($$('mainphoto'), minOpa);
}
rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" />';
}
$$('showArea').style.width = parseInt(w) + 'px';
var rLoad = document.createElement("div");
$$('photos').appendChild(rLoad);
rLoad.style.width = "1px";
rLoad.style.height = "1px";
rLoad.style.overflow = "hidden";
rLoad.innerHTML = rHtml;
}
</script> </div>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货