|
ตัวอย่างการแสดงผลภาพแบบหมุนเวียน Random Images
ตัวอย่างโค๊ดอยู่ข้างล่างนี้นะครับ คุณสามารถเพิ่มและลดภาพได้จากบรรทัด imgs[0] และ page[0] ตัวเลขคือลำดับการแสดงผลที่เพิ่มหรือลด ถ้าผู้ชมคลิกที่ภาพยังสามารถลิงก์ไปยังจุดเชื่อมโยงที่กำหนดได้ด้วยนะครับ
<script LANGUAGE="JavaScript">
<!-- Begin
var n = 0;
timedelay = 15; // 3 secs between pics
timedelay *= 1000;
var imgs = new Array();
imgs[0] = "images/easyhome01.gif";
imgs[1] = "images/easyhome02.gif";
imgs[2] = "images/ads468.gif";
imgs[3] = "images/easyhome03.gif";
imgs[4] = "images/easyhome04.gif";
var page = new Array();
page[0] = "http://www.easyhome.in.th";
page[1] = "http://www.easyhome.in.th";
page[2] = "http://www.isangate.com/ads.html";
page[3] = "http://www.easyhome.in.th";
page[4] = "http://www.easyhome.in.th";
function hook() {
var p = (n == 0) ? page[page.length-1] : page[n-1];
//window.open(p,"",windowprops);
window.open(p)
// or, instead of opening a new window,
// send them to the new page instead with:
// document.location.href = p;
}
function rotate() {
document.picform.slideshow.src = imgs[n];
(n == (imgs.length - 1)) ? n = 0 : n++;
window.setTimeout("rotate()", timedelay);
}
window.onload = rotate;
// End -->
</script>
<form name="picform">
<a href="javascript:hook();"><img name="slideshow" src="images1/ads468.gif" onmouseover="window.status = 'www.IsanGate.com Advertise';" width=468 height=60 border=0></a>
</form>
|
ตรงข้อความสีเหลือง src="images1/ads468.gif" คือภาพแรกที่ถูกแสดงก่อนนะครับ นำเอาโค๊ดนี้ไปไว้ในตำแหน่งที่คุณต้องการให้แสดงผลก็ใช้ได้แล้ว คงแก้ไขโค๊ดให้ตรงใจคุณได้เองนะครับ
|