News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

Adding sound or music to web pages - JavaScript tip

Started by ben2ong2, October 04, 2006, 04:18:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben2ong2


Introducing music on your personal web site adds flavor. This tip explains how sound or music can be played when a visitor passes the mouse pointer over an image.

Move your mouse over the keys below to play Brahms Waltz #3 - please make sure that the speakers are on.
Note: This tip will work only in Internet Explorer.

The code is simple and has to be included in the body section of your HTML document.

<BGSOUND SRC="#" ID="brahms" AUTOSTART="TRUE">

<IMG SRC="keys.gif" WIDTH="220" HEIGHT="126" BORDER="0"
onmouseover="document.all.brahms.src='brahms.mid'">


You can also play sounds when the mouse cursor passes over links. For this we use the anchor tag and the onmouseover JavaScript event handler function.

This link will play a beep sound when the mouse passes over it. Clicking this link will take you to the home page.
<BGSOUND SRC="#" ID="beep" AUTOSTART="TRUE">
<A HREF="some_page.html"
onmouseover="document.all.beep.src='beep.wav'">
Hotspot</A>





You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login