-
링크 클릭, 오버시 효과음내기- TIP 2008. 7. 18. 14:12
링크 클릭시 사운드 효과입니다.
온클릭과 온마우스오버 다 가능합니다.
<script LANGUAGE="JavaScript">
<!--
var ButtonSound = new Array();
ButtonSound[0] = "1.wav"; //사운드 파일의 경로
ButtonSound[1] = "2.wav"; //사운드 파일의 경로
ButtonSound[2] = "3.wav"; //사운드 파일의 경로
document.write('<BGSOUND ID="alertsound">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;
function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<ButtonSound.length;i++)
Str += "<EMBED SRC='"+ButtonSound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.alertsound:auEmb;
auCon.control = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? ButtonSound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}
function musicplay(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }
//-->
</script>
출처 : http://cafe.naver.com/ciel2004/181