哪位大侠 有图片滚动的特效的代码??效果是这样的:图片时动态的从数据库里读出来的,而且当显示到最后一张的时候,提示是最后一张图片,不是那种不间断的滚动的效果!!!
解决方案 »
- script优先级问题
- 各位大侠,谁那里有用js添加div,并且可以移动div的代码呀,谢谢
- 公司需要做这样一个类似的网站 请问一下整个工程找外包做需要大约多少rmb可以搞定
- Code Generator,根据qt的xml定义文件使用JS生成html和js代码的一些疑问
- js操作dom时浏览器的兼容问题
- [求助]赋值问题
- 【请教高手错误提示:“为空或不是对象”!解决立即给分】
- 在同一个页面里,如何使的 input 输入的 value 在下面的 url 中得到?
- 我发现,论坛上很多问题都是以前问过的,建议大家先使用搜索功能查找一下!!
- 关于JavaScript实现鼠标右键的问题。
- JavaScript 判断file 是否选择文件
- 动态添加的input里的数据如何获得?
http://blog.csdn.net/IBM_hoojo/archive/2010/06/07/5653246.aspx<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>tab.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.subject {
border: 1px solid black;
width: 200px;
height: 200px;
}
</style>
<script type="text/javascript">
var imgAry = new Array();
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/ed9e7094af4f2677d1135e93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/2f78156fb7c8dae681cb4a93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/cf4013658b43f3ccf7365493.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/2f78156fb7c8dae681cb4a93.jpg");
imgAry.push("http://hiphotos.baidu.com/%BA%EC%C2%A5%C7%E9%C3%CE/pic/item/ed9e7094af1f2677d0135e23.jpg");
window.onload = function () {
var oBox = document.getElementById("subjectBox");
var oShowId = document.getElementById("showId").value;
var subjectHtml = "";
for (var i = 1; i <= 4; i++) {
if (i == oShowId) {
subjectHtml += "<div id ='div_" + i + "' name='showDiv' style='display: block;' class='subject'>" + i + "<img src='" + imgAry[i-1] + "'/></div>"
} else {
subjectHtml += "<div id ='div_" + i + "' name='showDiv' style='display: none;' class='subject'>" + i + "<img src='" + imgAry[i-1] + "'/></div>"
}
}
oBox.innerHTML = subjectHtml;
showSubject2("next");
};
function setHide() {
var allDiv = document.getElementsByName("showDiv");
for (var i = 0; i < allDiv.length; i++) {
if (allDiv[i].style.display != "none") {
allDiv[i].style.display = "none";
}
}
}
//方法一:
function showSubject(flag) {
var oShowId = document.getElementById("showId").value;
var allDiv = document.getElementsByName("showDiv");
var len = allDiv.length;
//alert(oShowId + ":" + len);
setHide();//隐藏所有div
if (flag == "next") {
oShowId = eval(oShowId) + 1;
if (oShowId > len) {
oShowId = 1;
}
document.getElementById("div_" + oShowId).style.display = "block";
} else {
oShowId = eval(oShowId) - 1;
if (oShowId < 1) {
oShowId = len;
}
document.getElementById("div_" + oShowId).style.display = "block";
}
document.getElementById("showId").value = oShowId;
}
//方法二:
function showSubject2(flag) {
var allDiv = document.getElementsByName("showDiv");
for (var i = 0, len = allDiv.length; i < len; i++) {
if (allDiv[i].style.display == "block") {
allDiv[i].style.display = "none";
if (flag == "next") {
if (i < len) {
i += 1;
}
if (i >= len) {
i = 0;
}
} else {
if (i > 0) {
i -= 1;
}
if (i <= 0) {
i = len - 1;
}
}
allDiv[i].style.display = "block";
break;
}
}
setTimeout("showSubject2('next')", 1000);//动态更换图片
}
</script>
</head> <body>
方法1:
<input type="button" value="上" onclick="showSubject('prev')" />
<input type="button" value="下" onclick="showSubject('next')" />
<input type="hidden" id="showId" value="1" />
<br />
方法2:
<input type="button" value="上" onclick="showSubject2('prev')" />
<input type="button" value="下" onclick="showSubject2('next')" />
<div id="subjectBox">
</div>
</body>
</html>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/IBM_hoojo/archive/2010/06/07/5653246.aspx
在按钮事件中调用AJAX,去取数据库中的图像URL.取回赋给IMG的SRC.同时更改按钮中调用AJAX的ID参数.