Trước tiên bạn chỉ cần chèn script dưới đây vào phần trong trang của bạn
- Code:
<table border="0" cellpadding="0">
<caption><strong>Air Show Photos</strong></caption>
<tr> <td width="100%"><img src="plane1.gif" width="300" height="240" name="photoslider"></td>
</tr>
<tr>
<td width="100%"><form method="POST" name="rotater">
<div align="center"><center><p><script language="JavaScript1.1">
var photos=new Array()
var which=0
photos[0]="plane1.gif"
photos[1]="plane2.gif"
photos[2]="plane3.gif"
photos[3]="plane4.gif"
photos[4]="plane5.gif"
function backward(){
if (which>0){
window.status=''
which--
document.images.photoslider.src=photos[which]
}
}
function forward(){
if (which<photos.length-1){
which++
document.images.photoslider.src=photos[which]
}
else window.status='End of gallery'
}
</script><input type="button" value="<<Back" name="B2"
onClick="backward()"> <input type="button" value="Next>>" name="B1"
onClick="forward()"><br>
<a href="#" onClick="which=1;backward();return false"><small>Start Over</small></a></p>
</center></div>
</form>
</td>
</tr>
</table>
Có 2 điều bạn cần phải đổi trong đoạn mã trên. Đâu tiên là tag trong đoạn mã. Thay đổi cả thuộc tính “src” và “width/height” bên trong để tương ứng với ảnh được thể hiện đầu tiên. Không được thay đổi thuộc tính tên. Điều thứ hai cân thay đổi là biến photos[0],photos[1], … trong tag