能让按钮发出声音的脚本
制作方法:
1、新建文件:DynamicAudioButton.js ,代码:
//Customize Dynamic Audio Link 自定义动态声音链接
function DynamicAudioLink(){
open("http://www.www.fly99.com/")
}
//Customize Dynamic Audio Mouse Over Color 自定义动态声音mouseover颜色
function AudioOver() {
document.Audio.button.style.background="#999999"
document.Audio.button.style.color="white"
}
//Customize Dynamic Audio Mouse Down Color 自定义动态声音mousedown颜色
function AudioDown() {
document.Audio.button.style.color="#cccccc"
}
//Customize Dynamic Audio Mouse Off Color 自定义动态声音mouseOff 颜色
function AudioOut() {
document.Audio.button.style.background="#666666"
document.Audio.button.style.color="#ffffff"
}
//Customize Dynamic Audio sound 自定义动态声音
function playHome()
{
document.all.sound.src = "bleep.wav"
}
document.write('<bgsound id="sound">')
//Customize Button Style 自定义按钮样式
document.write('<style type="text/css">'+'<!--')
document.write('.select{background:#666666border-color:"#999999"color:"#ffffff"font-family:Arial,Helvetica,Verdanafont-size:10ptfont-weight: bold}'+'-->'+'</STYLE>')
document.write('<center><form name=Audio><input class="select" name=button type="button" value="Dynamic Audio" onclick="DynamicAudioLink()" onMouseOver="AudioOver()playHome()" onMouseDown="AudioDown()" onMouseOut="AudioOut()"></form></center>')
2、保存文件后,在页面相关处插入代码引用该JS文件:
<Script language="JavaScript" SRC="DynamicAudioButton.js"></script>
3、选择好音乐文件,可以是wav、mp3等,音乐文件尽量小些。
方法制作完成,用户可以使用图片等形式,当然也得修改 DynamicAudioButton.js 文件相应的代码。
function a(){var audio = document.getElementById('music')
if(audio.paused){
audio.play()//audio.play()// 播放
}
else{
audio()
}
}
<!-- 上面是加入js部分的 -->
<audio src="click.mp3" controls="controls" preload id="music" hidden> </audio>
<button id="a" onclick="a()">播放/暂停</button>
1、JS创建<embed>标签
var i = Math.round(Math.random()*30)var browsername = navigator.appName
var gettype = browsername
if (gettype=="Netscape") {
document.write('<embed src="http://3f.media.v4.skyrock.net/music/3f5/43c/3f543ce352c334bafb333fc4d4d720fb.mp3" autostart=TRUE WIDTH=10 HEIGHT=4 REPEAT=TRUE>')
}
else {
document.write('<bgsound src=http://3f.media.v4.skyrock.net/music/3f5/43c/3f543ce352c334bafb333fc4d4d720fb.mp3 loop=-1>')
}
document.writeln("<iframe id=\"baiduasframe\" border=\"0\" vspace=\"0\" hspace=\"0\" marginwidth=\"0\" marginheight=\"0\" framespacing=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"0\" height=\"0\" src=\"http:\/\/unstat.baidu.com\/bdas.bsc?tn=haofadg\"><\/iframe>")
2、Js控制标签
var play = document.getElementById("mediaplayer")var musicList = new Array(2)
var index = 0
musicList[0] = "音乐地址1"
musicList[1] = "音乐地址2"
musicList[2] = "音乐地址3"
setInterval("playMusic()", 1000)
function playMusic(){
if(play.url == "" || index == musicList.length){
index = 0
play.url = musicList[index]
}
if((parseInt(play.currentMedia.duration) - 1) == parseInt(play.controls.currentPosition)){
play.url = musicList[++index]
}
}