>>  Site Map >>  Forums >>  JavaScript_HTML

Forum module - topics in forum:



JavaScript_HTML - tìm hiểu và trao đỏi các mã java để làm trang web bạn sinh động hơn, các thủ thuật code html css



tạo một mã chơi nhạc radom bất kì

đoạn mã sẽ chon một bản nhạc bất kì trong danh sách và chơi khi nguòi dùng vào web của bạn

* cần cài đặt tổng số file - bài hát
* đặt chính sác địa chỉ url của mối bài

đặt đoạn mã sau vào chỗ thích hợp giũa < BODY > và < /BODY > tags in trong trang web của bạn

Code: :

<!--
****************************************************************
This script has been brought to you from:
www.websiteresources.com - "A place for all your website needs."
****************************************************************
Random Music Player
http://www.xaluan.com
Features: - randomly plays a music file
- works under Netscape & Internet Explorer
Enjoy!
***********************************************
Want more Website Resources? If so, check out:
http://www.websiteresources.com
***********************************************
-->
<script language="javascript">
<!--
// change this value to the # of music files you have
var totalmusicfiles = 5
var musicfile = new Array(totalmusicfiles + 1)
// change these values to indicate where each music file can be found
musicfile[1] = "1.mid"
musicfile[2] = "2.mid"
musicfile[3] = "3.mid"
musicfile[4] = "4.mid"
musicfile[5] = "5.mid"
// randomly select which music file to play
function selectmusicfile() {
var randfile = -1
while (randfile < 0 || randfile > totalmusicfiles || isNaN(randfile)) {
randfile = parseInt(Math.random() * (totalmusicfiles + 1) )
}
return randfile
}
// play the music
var selectedfile = selectmusicfile()
var mfile = musicfile[selectedfile]
mfile = mfile
app = navigator.appName
ver = navigator.appVersion
if (app == "Netscape") {
if (ver >= "3") {
document.write('<embed src="' + mfile + '" autostart=true loop=true volume=50
width=0 height=0 controls=smallconsole>')
}
} else {
document.write('<bgsound src="' + mfile + '" loop=INFINITE>')
}
// -->
</script>





Search from ALEXA


put your ads here