JavaScript - Click Sound Effect Ok For Firefox But Not Ie
Hi
this is my first forum post. I'm developing a website for use in Thai schools in which clicking on link (at the beginning of a line of English text) starts a sound file (ogg or mp3). I've been using the Mouseover/Click sound effect script from by JavaScript Kit (www.javascriptkit.com). It works as designed in Firefox and Opera but doesn't in IE8. The script relies on HTML5 functionality so it should be compatible with IE8 (so I understand). I'm using Ubuntu 10.04 with Windows XP SP3 as the guest OS on VirtualBox. it seems to be a problem specific to IE8 (perhaps, not too surprising!) since the script works OK for Firefox and Opera. Here is the script Code: var html5_audiotypes={ //define list of audio file extensions and their associated audio types. Add to it if your specified audio file isn't on this list: "mp3": "audio/mpeg", "mp4": "audio/mp4", "ogg": "audio/ogg", "wav": "audio/wav" } function createsoundbite(sound){ var html5audio=document.createElement('audio') if (html5audio.canPlayType){ //check support for HTML5 audio for (var i=0; i<arguments.length; i++){ var sourceel=document.createElement('source') sourceel.setAttribute('src', arguments[i]) if (arguments[i].match(/\.(\w+)$/i)) sourceel.setAttribute('type', html5_audiotypes[RegExp.$1]) html5audio.appendChild(sourceel) } html5audio.load() html5audio.playclip=function(){ html5audio.pause() html5audio.currentTime=0 html5audio.play() } return html5audio } else{ return {playclip:function(){throw new Error("Your browser doesn't support HTML5 audio unfortunately")}} } } //Initialize two sound clips with 1 fallback file each: var a=createsoundbite("chot_pic01.ogg", "chot_pic01.mp3") var b=createsoundbite("chot_pic02.ogg", "chot_pic02.mp3") ............................. ............................. I only know a little Javascript at present, so I would be thankful of any help Similar TutorialsI got this javascript Click sound effect to work - http://www.javascriptkit.com/script/...oundlink.shtml My question is how do I make it work on my iphone4 ? I tested the above site on my phone and there is no audio when I tap the screen. The html5 <audio> seems to work with my mobile device on this site - http://css-tricks.com/examples/SoundOnHover/ I am new to javascript thx Hi people ! I went to this page: http://www.javascriptkit.com/script/....shtml#current and I applied that script to my website, everything work perfectly. I only have a question about it: * What should I add to the code to avoid the sound activate even when I'm hovering over the margin of the image? * Would it be possible that the sound activate only when the mouse is hovered over the image and not the margin as well ? * Is the only solution; to insert every image in their own div and then letting the div handle the margin? this is the site www.blackbandanamovement.com the images I'm talking about are in the footer. thanks in advance Hi all, I am using the following script posted on this site: http://www.javascriptkit.com/script/...oundlink.shtml It works great, but I want to extend this script and mute the sound using a checkbox. This checkbox has the id: sound. If checked, I want to hear the sounds, when unchecked, no sounds should be heard. This is the code I currently have for the checkbox: Code: function playSound() { if (document.getElementById('sound').checked){ -something needs to be added here to make it work?- } } Anyone have an idea how to make this work? Many thanks What is the correct code to make a sound play every time you click a certain image? All the codes I've found online aren't working, or I'm not inputting something correctly..
Hi to everybody, I created a site and added a sound on click events a hover. But not all my website visitors prefer it, so I would like to add a button to mute these click sounds. Is this possible? Please help me because I don't have a clue on how to proceed. Thanks very much in advance Dimitri hi i have the following code which works fine in IE but nothing happens in firefox. Code: <html> <bgsound id="sound"> <script> function PlaySound(url) { document.all.sound.src = url; } </script> <body> <a href="#"><img src="images/butters.jpg" onMouseOver="PlaySound('http://www.pacdv.com/sounds/sounds/sound38.mp3')" /></a> </body> </html> Any one know of any good ways to make sound work in firefox? ta Hi, JS newbie here trying to cobble together enough to get this page done. Here's the snippet I'm having trouble with (sorry, I know it's sloppy, if you have a better way to do it by all means please post): Code: function showAdv() { if(claroxanadvanced.style.display == "none") { claroxanadvanced.style.display = "block"; claroxanoriginal.style.display = "none"; smokersformula.style.display = "none"; } else { } } function showOri() { if(claroxanoriginal.style.display == "none") { claroxanadvanced.style.display = "none"; claroxanoriginal.style.display = "block"; smokersformula.style.display = "none"; } else { } } function showSmo() { if(smokersformula.style.display == "none") { claroxanadvanced.style.display = "none"; claroxanoriginal.style.display = "none"; smokersformula.style.display = "block"; } else { } } And the page where it is implemented: http://www.claroxan.com/test/ Firefox's debug window says it might be an issue of undeclared variables - 'claroxanadvanced', 'claroxanoriginal' and 'smokersformula' are all div IDs in the html, what line should I put to declare them? Thanks Hi I wrote following code for the purpose to single right click to open new window, while left click would open another window. It works for IE but does not work for Firefox. Please help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US|zh-Hans|zh-Hant"> <head> <title>Javascript Question</title> <META NAME="LANGUAGE" CONTENT="en"> <META NAME="DOCUMENTCOUNTRYCODE" CONTENT="us"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=GB18030"> <script language='Javascript' type='text/javascript'> var rightClick = false; window.document.oncontextmenu = new Function("return false"); window.document.onmouseup = mouseUp; function mouseUp(e) { if (!e) var e = window.event; if (e.which) rightClick = (e.which == 3) else if (e.button) rightClick = (e.button == 2); if (rightClick) window.open('http://www.yahoo.com/'); } </script> </head> <body> <a href="#" onclick="window.open('http://www.google.com/')" onmouseup>Open New Window</a> </body> </html> Hi guys, I created a firefox extension a while ago & have just realised that the right click menu's don't seem to appear anymore... Have the methods I'm using been deprecated? Could someone point me in the right direction? Here's my old code.... Code: // This is our javascript, which will check the selected link or hyperlink function myfunction() { if (gContextMenu.isTextSelected) { var focusedWindow = document.commandDispatcher.focusedWindow; if (focusedWindow == window) focusedWindow = getBrowser().contentWindow; var url = focusedWindow.getSelection().toString(); var mySplitResult = url.split("\n"); for(i = 0; i < mySplitResult.length; i++){ window.open('http://mysite.com/mypage.php?url=' + mySplitResult[i], 'window name') } } else { try {url = gContextMenu.linkURL} // new FF, other? catch(e) { try {url = gContextMenu.linkURL()} // old FF, SM, other? catch(e) {url = String(gContextMenu.link)} // either FF, other? } window.open('http://mysite.com/mypage.php?url=' + url, 'windowname2') } } Many thanks in return! I have an ajax member search form that I'm just about done with but I have a couple of really irritating firefox issues. The first one is the lack of support of the click() method. I added the following but it still doesn't want to work: Code: <script> if(typeof HTMLElement != 'undefined' && !HTMLElement.prototype.click) { HTMLElement.prototype.click = function() { var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); } } </script> The second issue I'm having is with dependent dropdown selects not hiding in firefox. This seems to be due to the other functions that need to trigger onload and is dependent on what order it's loaded. Here's how I'm handling the onload functions: Code: <script> function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { ajaxFunction(document.getElementById('country').value); handleOnChange(country); setupDependencies('cbcheckedadminForm', 'adminForm', 'locationsearch'); handleOnChange2(cb_state); }); </script> I don't have an issue with either of these in chrome. IE is a WHOLE other story, it's all kinds of wonky there. I still need to go through and do some debugging for that. Any quick ideas off hand on these two issues? I'll try and post the full php file in a reply. Ok know those people who are in the bad habit of double clicking everything? Well my site breaks if they double click it... is there a script I can use that won't let my functions run more then once every so many seconds? to avoid double clicking errors? Hi I'm wanting to add a sound to an image when it is clicked. Basically when you click a picture of a mouse is squeaks. Can someone help me with the code for this? I think its Javascript which is a aboit scary for me ha! I'm hoping its not to complicated and confusing for my brain!! Cheers C Hey guys, I need some help. I have divs placed in a html document, and what I need to do is have a sound play when a person is to hover their mouse over the,. I used this code that I've butchered together from researching on the internet, but it just isn't working. The sound plays automatically as soon as the site loads. Can you please help me? Here is my code: Code: <html> <head> <script> function EvalSound(soundobj) { var thissound= eval("document."+soundobj); thissound.Play(); } </script> <embed src="C.mp3" autostart=false width=0 height=0 name="C" enablejavascript="true"> <embed src="D.mp3" autostart=false width=0 height=0 name="D" enablejavascript="true"> </head> <link rel="stylesheet" type="text/css" href="NavTest.css"> <div id=red alt="#" onMouseOver="EvalSound('C')"></div> <div id=blue alt="#" onMouseOver="EvalSound('D')"></div> </html> Thank you! [: Sorry, maybe I should also mention that my knowledge of Javascript is NONE! :| Hi there Looking at adding a sound file to a game to play when an image, a .png image is pressed.. it will be a simple 1sec (or less) sound file i.e. bell, whistle etc. Just looking at some help on where to start with the code. Many thanks LL Hello Everyone! I am looking for help with this script and I was wondering if someone could help me out? I want to play a sound on a mouse click, which there are a ton of scripts out there that do this. Here is my problem I want to be able to let the users shut the sound on and off. This is for a feature to my site that I am building that is just using javascript and html. Here is what I have so far below. I would also like to have a div to show if the sound is on or off. The only thing that I am looking for the javascript to play and stop the sound file. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript"> var theSound = "on"; function playSound(){ if(document.getElementById("mute").checked == false){ document.getElementById("theSound").style.display = "block"; //isert play sound code here } } function muteSound(){ document.getElementById("theSound").style.display = "none"; //insert stop sound code here } </script> </head> <body> <form name="soundTest"> <input name="sound" type="checkbox" value="on" id="mute" />Mute </form> <p onmouseover="playSound()" onmouseout="muteSound()">Mouseover this to make the "Sound".</p> <!--This is just a div that represents a sound playing.--> <div id="theSound" style="display:none; background:#FF0000; padding:10px; font-size:36px">SOUND!</div> </body> </html> Note: That this script just shows a mute check box. I think I am going to to buttons for start and stop. Thanks for the help in advance and look forward to hearing from you. Chris hi there, im trying to get a sound effect to play when a slideshow runs. the user selects the sound from a drop down menu on each image. The sound play when selected. But i need some way to pass it into the function that starts the slideshow. I am using pixtastic library to add effects to the images, and jquery (with cycle plugin) to perform the slideshow. The sounds ive put in work when selected, but i need to write a function to play them when the slideshow runs (this is where im stuck!) The library is soundmanager2 Here is the code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="js/pixastic.core.js"></script> <script type="text/javascript" src="js/pixastic.jquery.js"></script> <script type="text/javascript" src="js/actions/sepia.js"></script> <script type="text/javascript" src="js/actions/flipv.js"></script> <script type="text/javascript" src="js/actions/emboss.js"></script> <script type="text/javascript" src="js/actions/blur.js"></script> <script type="text/javascript" src="js/actions/solarize.js"></script> <script type="text/javascript" src="js/actions/edges.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <!-- include Cycle plugin --> <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script> <script type="text/javascript" src="js/Soundmanager/script/soundmanager.js"></script> <script> function change_image(id, effect) { Pixastic.process(document.getElementById(id),effect); } function startShow() { //get the canvas elements on the page var canvases = document.getElementsByTagName("canvas"); var viewpane = document.getElementById("slideshow"); for(i=0;i<canvases.length;i++) { viewpane.appendChild(canvases[i]); } $('#slideshow').cycle({ fx: 'all' // choose your transition type, ex: fade, scrollUp, shuffle, etc... }); } </script> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="css/main.css" type="text/css" /> <title>My Slideshow</title> </head> <body> <div> <!-- soundManager appends "hidden" Flash to the first DIV on the page. --> </div> <div class="wrap"> <h1 id="logo"><a href="javascript:location.reload(true)">My Slideshow!</a> <br /></a></h1> <ul id="menu"> Welcome to my slideshow, click view show to start<p>alternatively, click the headline to start again</p> </ul> <div id="text"> <h2>Edit the images and start the show!</h2><p><h3>You can add more than one effect to each image!</h3> <div id = "slideshow"> <iNPUT TYPE=BUTTON OnClick="startShow()" VALUE="View The Show"> </div> </div> <div id="leftcolumn"> <div id ="firstImage"> <img id="image1" src = "images/image1.jpg"></image> <form name="first_pic" id="first_pic"> <select name="image1" onchange = "change_image(this.name,this.value);"> <option value="blank">Edit the Image</option> <option value="sepia">Sepia</option> <option value="flipv">Flip Vertical</option> <option value="emboss">Emboss</option> <option value="solarize">Solarize</option> <option value="blur">Blur</option> <option value="edges">Edged</option> </select> <select name="image1" onchange = "soundManager.play(this.value);"> <option value="">Choose a sound</option> <option value="beep">Beep</option> <option value="gangsta">Gangsta</option> <option value="glass">Glass</option> <option value="page">Page turn</option> </select> </div> </p> </div> <div id="rightcolumn"> <div id = "secondImage"> <img id="image2" src = "images/image2.jpg"></image> <form name="first_pic" id="first_pic"> <select name="image2" onchange = "change_image(this.name,this.value);"> <option value="blank">Edit the Image</option> <option value="sepia">Sepia</option> <option value="flipv">Flip Vertical</option> <option value="emboss">Emboss</option> <option value="solarize">Solarize</option> <option value="blur">Blur</option> <option value="edges">Edged</option> </select> <select name="image2" onchange = "soundManager.play(this.value);"> <option value="">Choose a sound</option> <option value="beep">Beep</option> <option value="gangsta">Gangsta</option> <option value="glass">Glass</option> <option value="page">Page turn</option> </select> </div> </div> <div id="green_bubble"> </div> </div> <div id="footer"> <div class="wrap"> <div id="bubble"></div> <div id="copyright"> </div> <div class="clear"></div> </div> </div> <script type="text/javascript">soundManagerInit();</script> </body> </html> Thanks! Hey guys, first I am new and I don't really know where this goes but I am wanting some help with developing a program that converts Sound (Speech or more preferably a sound... Like a frequency) to a Keystroke or code.. I know a little bit of C++ if that helps.. (I also Have Visual Studio 2013) Thanks guys
Reply With Quote 12-21-2014, 12:36 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Not possible using Javascript. The Warrington players can hang their heads high. - Commentator, BBC Radio 2 Please help, I have a page with 3 images. I want my visitors to hear an mp3 audio once they hover their mouse on each image. image1 = audio1.mp3 image2 = audio2.mp3 image3 = audio3.mp3 But here are the challenges. 1- I want the audio files to play on the same page where the images are, without opening a new page. 2- I don't want the users to be asked to accept any kind of plugins (such as Windows Media Player). Which means everything needed to run the script should already exist on that page. 3- I want it to be played on the 3 major browsers (IE, Firefox, Chrome) Is this possible? I'm not good at Javascript, but I will understand to do my best to understand your instructions. I spent a long time looking online, but most of what I found is only compatible in one browser or the other. Any help would be appreciated. Just so you know: this is not my idea, the person whose site this is wants a short blip sound played whenever you roll over the links in the sidebar. I know it's not advised, but she insists. So can anybody tell me how this is done? I've tried implementing a few scripts but no luck in Firefox or Chrome. Thanks. How can I play a sound when I click an image, without the information bar popping up at top? I've looked all over, and I've tried a few javascript-only methods but none have worked for me.. Is flash the only way to go?
|