Give me an example of adding sound effects
A script that makes a button sound
Production method:
1. Create a new file: DynamicAudioButton .js, code:
//Customize Dynamic Audio Link Custom dynamic sound link
function DynamicAudioLink(){
open("/") p>
}
//Customize Dynamic Audio Mouse Over Color Customize the dynamic sound mouseover color
function AudioOver() {
document.Audio. button.style.background="#999999"
document.Audio.button.style.color="white"
}
//Customize Dynamic Audio Mouse Down Color Customize dynamic sound mousedown color
function AudioDown() {
document.Audio.button.style.color="#cccccc"
}
//Customize Dynamic Audio Mouse Off Color Customize dynamic sound mouseOff color
function AudioOut() {
document.Audio.button.style.background= "#666666"
document.Audio.button.style.color="#ffffff"
}
//Customize Dynamic Audio sound Customize dynamic sound
function playHome()
{
document.all.sound.src = "bleep.wav";
} p>
document.write('lt;bgsound id="sound"gt;')
//Customize Button Style Customize button style
document.write(' lt;style type="text/css"gt;' 'lt;!--')
document.write('.select{background: #666666; border-color: "#999999"; color: "#ffffff"; font-family: Arial, Helvetica, Verdana; font-size: 10pt; font-weight: bold;}' '--gt;' 'lt;/STYLEgt;')
document.write('lt; centergt; lt; form name=Audiogt; lt; input class="select" name=button type="button" value="Dynamic Audio" onclick="Dyna
micAudioLink()" onMouseOver="AudioOver(); playHome()" onMouseDown="AudioDown()" onMouseOut="AudioOut()"gt;lt;/formgt;lt;/centergt;')
2. After saving the file, insert code to reference the JS file at the relevant place on the page:
lt;Script language="JavaScript" SRC="DynamicAudioButton.js"gt;lt;/scriptgt;
3. Select the music file, which can be wav, mp3, etc. The music file should be as small as possible.
The method is completed. The user can use pictures and other forms. Of course, the DynamicAudioButton.js file must be modified accordingly.