Article introduction:
Generally speaking, buttons on web pages do not trigger sound events. If you want a button to make a sound in response to mouse movements, we can write a JavaScript script code to achieve it.
A script that can make buttons make sounds. Now you don’t need to make Flash buttons. I felt pretty good after trying it out.
Production method:
1. Create a new file:
The following is a quote:
DynamicAudioButton.js, code:
//Customize Dynamic Audio Link Customize dynamic sound link
function DynamicAudioLink(){
open(" http://www.pcedu.com.cn ")
}
//Customize Dynamic Audio Mouse Over Color Customize 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";
}
document.write('<bgsound id="sound">')
//Customize Button Style Customize button style
document.write('<style type="text/css">'+'<!--')
document.write('.select{background:#666666;border-color:"#999999";color:"#ffffff";font-family:Arial,Helvetica,Verdana;font-size:10pt;font-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. After saving the file, insert code to reference the JS file at relevant places on the page:
The following is a reference fragment:
<Script language="JavaScript" SRC="DynamicAudioButton.js"></script>
3. Choose a good music file, which can be wav, MP3, etc. The music file should be as small as possible.
After the method is created, users can use pictures and other forms. Of course, they must also modify the corresponding code of the DynamicAudioButton.js file.