Example: use Javascript to create a sound Button _ Javascript tutorial

Source: Internet
Author: User
Javascript: Example: using Javascript to create sound buttons, Javascript tutorial

Introduction:

In general, buttons on a webpage do not trigger sound events. If you want the button to respond to the sound of the mouse action, you can write a JavaScript script code.

The script that can make the button sound. You don't need to make the Flash button. I feel pretty good when trying it out.

  Production method:

1. Create a file:

The following is a reference clip:
DynamicAudioButton. js, code:
// Customize Dynamic Audio Link custom Dynamic sound Link
Function DynamicAudioLink (){
Open ("http://www.pcedu.com.cn ")
}

// Customize Dynamic Audio Mouse Over Color custom Dynamic sound mouseover Color
Function AudioOver (){
Document. Audio. button. style. background = "#999999"
Document. Audio. button. style. color = "white"
}

// Customize Dynamic Audio Mouse Down Color custom Dynamic sound mousedown Color
Function AudioDown (){
Document. Audio. button. style. color = "# cccccc"
}

// Customize Dynamic Audio Mouse Off Color custom Dynamic sound mouseOff Color
Function AudioOut (){
Document. Audio. button. style. background = "#666666"
Document. Audio. button. style. color = "# ffffff"
}

// Customize Dynamic Audio sound custom Dynamic sound
Function playHome ()
{
Document. all. sound. src = "bleep.wav ";
}

Document. write (' ')

// Customize Button Style Custom Button Style
Document. write (' '+' '+'')

Document. write (' ')

2. After saving the file, insert the code in the relevant part of the page to reference the JS file:

The following is a reference clip:
Script

3. Select a music file, such as wav and MP3, which should be as small as possible.

After the method is created, you can use images and other forms. Of course, you must modify the corresponding code of the DynamicAudioButton. js file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.