• Page 1 of 1
  • 1
Forum moderator: bigblog  
hover sound
angry_jin
Posts: 53
Reputation: 0

Message # 1 | 3:00 PM
ok i want to add sound to my menu ,,like when mouse hover on it it produces sound(click etc).
and when i click on one of menu then it also plys sound (tick etc)
i know their is a way that i will make a flash .swf etc
but is their any other way?

the quieter you become, the more you are able to hear.
joexyz
JOE-vascript
Posts: 1770
Reputation: 78

Message # 2 | 5:12 PM
angry_jin, if you want different sound for each menu item, paste this line to the Bottom part of website template:

Code
<span id="sound"></span>
<script type="text/javascript">function hoversnd(f) {document.getElementById("sound").innerHTML='<audio autoplay="1"><source src="' + f + '" type="audio/wav"></audio>';}</div>


And for menu, an item will be like this:

Code
<a href="#" onmouseover="hoversnd('http://bigblog.ucoz.net/src/Alarm08.wav');">Item text</a>


(Replace http://bigblog.ucoz.net/src/Alarm08.wav with your sound file's URL address).


If you want just one sound for every menu item, paste this line to the Bottom part of website template:

Code
<span id="sound"></span>
<script type="text/javascript">function hoversnd() {document.getElementById("sound").innerHTML='<audio autoplay="1"> <source src="http://bigblog.ucoz.net/src/Alarm08.wav" type="audio/wav"></audio>';}</div>


(Replace http://bigblog.ucoz.net/src/Alarm08.wav with your sound file's URL address).

And for menu, an item will be like this:

Code
<a href="#" onmouseover="hoversnd();">Item text</a>


For playing after clicking, replace onmouseover with onclick at the menu element.

Note: This code plays a .wav file. If you want to play an .mp3 file, replace wav with mpeg in the code from the Bottom part of website template.

Demo: Fiddle.

hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau

sometimes i lurk here
angry_jin
Posts: 53
Reputation: 0

Message # 3 | 2:30 PM
let me try, i will give u answer soon bigboy, wink

Added (2014-12-01, 1:30 PM)
---------------------------------------------
i think i m doing ssomething wrong,


the quieter you become, the more you are able to hear.
angry_jin
Posts: 53
Reputation: 0

Message # 4 | 2:39 PM
have a look i m talking about this,bigblog,
Attachments: 9243702.jpg (235.0 Kb)

the quieter you become, the more you are able to hear.
joexyz
JOE-vascript
Posts: 1770
Reputation: 78

Message # 5 | 5:25 PM
angry_jin, I just figured out, that I wrote </div> instead of </script> in the code from the bottom part.

Well, if you are using a standard menu (generated by system), you have to put the menu code ($SMENU_X$/$NMENU_X$) inside of:

Code
<div id="menusnd">

  and  

</div>


And you have to use this code for the bottom part:

Code
<span id="sound"></span>  
<script type="text/javascript">function hoversnd(){
     document.getElementById("sound").innerHTML='<audio autoplay="1"> <source src="http://bigblog.ucoz.net/src/Alarm08.wav" type="audio/wav"></audio>';
}
var menusnd = document.getElementById("menusnd");
var a = menusnd.getElementsByTagName("a");
for(var i=0; i<a.length; i++) {
a[i].addEventListener("mouseover", hoversnd);
}</script>

(JavaScript code fixed by vmarci21)

hey i'm joe and i do not work for the company anymore, please contact other staff or tech support
icon by ch-chau

sometimes i lurk here
angry_jin
Posts: 53
Reputation: 0

Message # 6 | 8:05 PM
now , works thanks buddy.
the quieter you become, the more you are able to hear.
  • Page 1 of 1
  • 1
Search: