|
藍森林 http://www.lslnet.com 2006年8月25日 8:28
請教-網頁輪顯圖片怎麼做的?
大家看看http://hgxn.vicp.net/index.asp
她上方的圖片美刷新一次換一個,怎麼做的?
謝謝 |
隨機顯示?
[html]
<script language="javascript">
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
url="http://www.lemongtree.net/bbs/";
alt="www.lemongtree.net";
banner="http://www.lemongtree.net/logo.gif";
}
if (ad==2) {
url="http://showtop.net";
alt="ShowTop.Net";
banner="http://deepsky.y365.com/images/banner.gif";
}
if (ad==3) {
url="http://www.gamvan.com/";
alt="http://www.gamvan.com/link/imgs/gv.gif";
banner="http://www.gamvan.com/link/imgs/gv.gif";
}
if (ad==4) {
url="http://www.blueidea.com/";
alt="http://www.blueidea.com/";
banner="http://www.blueidea.com/img/common/logo.gif";
}
if (ad==5) {
url="";
alt="";
banner="";
}
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=88 height=31 ')
document.write('alt=\"' + alt + '\" border=0></a>');
</script>
[/html]
可以另存為JS文件調用,具體調用方法見這裡:
http://www.lemongtree.net/bbs/forum_posts.asp?TID=936&PN=1&TPN=1 |
請教一下,我用隨機數做得為什麼不對?
[html]
<script language="javascript">
function change()
{
i=Math.floor(Math.random()*16)
oImg.src="icon/icon"+i+".gif"
}
onload=change()
}
</script>
<img src=icon/icon0.gif id="oImg">
[/html] |
從別人的網站扣出來的
上次是誰問看到這個網站的效果
要代碼
我就給摳出來了
[html]
<html>
<head>
<title>test
</title>
<script language='javascript'>
isns = navigator.appName == "Netscape";
img1=new Image()
img2=new Image()
img3=new Image()
img4=new Image()
img5=new Image()
img1.src='http://www.lnsyzx.com/images/picture/p1.jpg'
img2.src='http://www.lnsyzx.com/images/picture/p2.jpg'
img3.src='http://www.lnsyzx.com/images/picture/p3.jpg'
img4.src='http://www.lnsyzx.com/images/picture/p4.jpg'
img5.src='http://www.lnsyzx.com/images/picture/p5.jpg'
nn=1
function change_img()
{
eval('document.pic.src=img'+nn+'.src');
nn++;
if(nn>5) nn=1
if(!isns)
{
pic.filters.item(0).apply()
pic.style.visibility='visible'
pic.filters.item(0).play()
setTimeout("pic.style.visibility='hidden'",4000);
}
else
document.pic.visibility='visible'
tt=setTimeout('change_img()',4000)
}
</script>
</head>
<body onload="change_img();">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="150" height="150"><tr><td width="100%"><p align="center"><a href="http://www.lnsyzx.com/about/xxgm05_1.asp"><img src=images/picture/p1.jpg width=150 height=150 border=0 name=pic style='visibility:hidden;filter:revealtrans(duration=2.0,transition=12)'></a></td></tr></table></center></div></td></tr></table>
</body>
</html>
[/html] |
php
[code]<img src="images/img_<?php echo rand(1,6); ?>.gif">[/code]
asp
[code]<%
randomize
dim k
k=cint(rnd*6)
if k=0 then
k=k+1
end if
%>
<img src="images/img_<%=k%>.gif">[/code] |
謝謝大家!
長見識 |
ps:論壇
[html]
<script language="javascript">
function change()
{
i=Math.floor(Math.random()*16)
oImg.src="icon/icon"+i+".gif"
}
window.onload=change
</script>
<img id="oImg">
[/html] |
|