Get An Audible Click Sound File To Run Every Time The Function Runs
Apr 27, 2011
I have a self project I am exploring. I would like to play a simple sound file each time a function is run. The function runs every second, so, basically, I am just trying to get an audible click sound file to run every time the function runs. I do not know how to play a sound file thru javascript. Here is the code file thus far...
function update(value1){ doAjax("behind_scan.php" , "id="+value1); }function doAjax(url , str ){ xmlhttp=GetXmlHttpObject(); if (xmlhttp==null){ alert ("Browser does not support HTTP Request"); return; }url=url+"?"+str; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }function stateChanged(){ if (xmlhttp.readyState==4){ //document.getElementById("txtHint").innerHTML=xmlhttp.responseText; //alert(xmlhttp.responseText) document.forms.myform.scanner.value = ""; document.forms.myform.scanner.focus(); }}function GetXmlHttpObject(){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); }if (window.ActiveXObject){ // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; }
This pages calls a function on a separate php page to run 2 mySQL queries, the value must be put in the text 3 times in quick succession before the database is altered. I've tried all the other functions and they seem to be fine, AJAX is my weakness but I need it for the main functionality of my website. I need this to work.
How to play sound file like .wav file with javascript and/or DHTML when some one mouseover to a link. I have done this... but it only works in IE while it does not work in other browsers like firefox and chrome.
I want to play a repetitive sound, and have a user click on a button each time it plays (say 5-10 times) and measure how far off he is from the sound each time.
The only way I know to play a sound in JS is bgsound, and I know how to loop and pause, so as to do the 1st part. I haven't figured out how to then test the delay in response. Since some of the responses may also be *before* the sound plays by some milliseconds, that also compicates it.
My real question is, can this even be done in JS, or should I be in PHP, ASP, or do you have another suggestion. I'm thinking it needs to run client-side so there are no network delays, and the results would be reasonably accurate on different machines. I could easily write it in VB but I don't want them to have to download anything. I'd just like it to run from the page.
I have a for loop which has a length of 8. It's meant to run through an array of objects and bind a click function to all of them. So the alert should run a range 0-7 but instead it returns 8 no matter which object is being clicked.
Using JavaScript, I require a code that allows me to play .wav sound files randomly and automatically on page start-up, I also need them to loop as they are drum beats. The plan: to load my web page and hear a random drum beat that loops continuously. I need it to be compatible with most, if not all Internet browsers (Chrome, Internet Explorer, Firefox and Opera are crucial) and to state what sound file is playing on the page (allowing me to identify the looping drum beat/sound file), and if possible to provide a link to the actual sound file for download.
I have a function which is called twice. It allows the elements of an array to be set to a different color, successively:
function ln8 (arrayA,color,current) { var arrayB=(typeof arrayA == 'string')? arrayA.split(',') : arrayA; var line = document.getElementById(arrayB[current]);
<script type="text/javascript" src="js-bin/silent_refresh.js"></script> In a javascript named silent_refresh.js: (make sure the script is in a folder called 'js-bin') window.onload = doLoad;
function doLoad() { setTimeout( "refresh()", 60*1000 ); }
function refresh() { window.location.reload( false ); }
The page will refresh every 60 seconds - Just alter the 60 to whatever time you require.
question: if you want a link which simply runs a js function is it acceptable to have no href? the problem with this is the cursor doesnt change when you hover over, but if you put # as the href it jumps to the top of the screen which is sometimes unacceptable. what it the best solution to this? granted you could do event handling behind the scenes and just intercept the clicks and prevent the href from going anywhere, but sometimes you just want to stick an onclick on the anchor tag!
Problem in the timing of the script. The problem is that when I try to get an id of an object that was added by ajax, the script doesn't recognize it. The html: <select id="categories" name="categories"> <option value="3">aa</option> <option value="43">bbb</option> </select>
When I load the page, there is this script that get the value of the #categories and use ajax to fill another select and in the same ajax, I load images by another function using the new select input that was created: function fill_subcategories(){ parent=$("#categories").val(); $.ajax({ type: "post", url: "ajax/sub_galleries.php", data: 'parent='+parent, success: function(data){ $('#sub_categories').html(data); }}); show_exist_imgs() }
This fills this div: <select name="sub_categories" id="sub_categories"></select> Right after filling the #sub_categories, I use another ajax that get images of the new id of the #sub_categories, and here I get the problem.. the js: function show_exist_imgs(){ g_id=$('#sub_categories').val(); $.ajax({ type: "post", url: "ajax/show_exist_imgs.php", data: 'g_id='+g_id, success: function(data){ $('#exist_files').html(data); }}); } This script doesn't recognize the id of the new $('#sub_categories') select input.. why is that?
I have created some code that alerts me the contents of all the child divs inside a main div
function CheckEventLayout(){ //check all divs in area and resize overlapping divs var RunOnce; if( RunOnce != true ){ var StartTimes = new Array(); var EndTimes = new Array(); var i = 0; $("div#day-view-overlay").children("div.day-view-appointment").each(function(){ var DoOnce; if( DoOnce != true ){ alert($(this).html()); ..... CheckEventLayout();
The problem is this code is on a page that is loaded via post and if you go off the page and then back onto it jquery seems to attach the function again so it runs twice. So need to unbind this function before the script runs again.
If this search function is included in an include file with other functions it will run more than once if you click another function first, then come back to it to do another search.
For example if I click the next page function, then decide to click for a new search it runs more than once: Next page function:
Code: $(document).ready(function() { $('a#nextpage').click(function() { var page = $(this).attr('page'); var searchval = $(this).attr('schval'); var maxpage = $(this).attr('maxpage'); $.post("findowner.php", { p1 : searchval, page : page }, function(data){ if (data.length>0){ $("#ownerIDdiv2").html(data); } }); }); }); //end
However, if I put the first search function in a separate include file all works perfect. Why it runs multiple times if it is grouped among other functions?
I've got an array of names, and one ID. I need to run an ajax call using the ID and each lastname, until I get a successful hit on the ajax call. I can't quite figure out how to determine if the function that runs the ajax call has succeeded or not, it always returns false for me... Here's the code for the loop:
I wrote a program which showing the difference of two auto generated values. its working perfectly but when i tried to set if() operator to make sound if the difference higher then 7 its not working.
I think something wrong in my code.
Orginal working code here...
But when i put if() operator under processdata() function the whole things hanged and no sound are palying.
I applied it like this way.
I dont know why its not working....i want to play and stop sound name sample.wav from my harddrive if difference range higher or lower than 7.....
When the JS file is not working at the time of Ajax files is called. on first time the onmouseover JS is working but , if you call the ajax JS is not working.
I'm trying to make buttons that change from one color to another when you click them and change back when you click them a third time. I wrote this page (http://cf.lehigh.edu/ems/test.html) but it only works on Firefox(Not IE or Chome, untested on safari or Opera). I'm using javascript to change the button colors. Is there another way to do this that works universal or another tool such as CSS?
in my web application i've disabled all F keys with common script like this below, i use F keys for open some different popups, but only F12 key have problem, if i press F12 first time it run well and open my popup, but if i close it and i immediatly press F12 again it doesn't open my popup but it open developer tool window.It run well only if before i click with mouse onto the page, but i do not have to use the mouse.
I am new to javascript (4 months), I would like to add an hour to the current time each time a button is clicked.
I have this code: var hourstbutton=document.getElementById("button3"); hoursbutton.onclick=function() { var divlink=document.getElementById("math3"); var newtime2=new Date(); var currenthours2=newtime2.getHours()+1; var currentmins2=newtime2.getMinutes(); var currentsecns2=newtime2.getSeconds(); var ampm2= (currenthours2>=12) ? "P.M." : "A.M."; if (currenthours2>=13) { currenthours2-=12; }if(currenthours2<1){ currenthours2=12; }if(currentmins2<10){ currentmins2= "0" + currentmins2; }if(currentsecns2<10){ currentsecns2="0" + currentsecns2; } divlink.innerHTML=currenthours2+":"+currentmins2+":"+currentsecns2+ " "+ampm2;
How do I tie the number of button clicks into the number of times this code is executed?
I'm working on a project where a user is going to click on a name in a list, some code will happen, and then some JavaScript will get a corresponding blob from a server and display it in a new text file.however, the time that the text file is both open and active also needs to be saved. I'm planning on using an ActiveXObject to display the data, but I haven't been able to find anything using either JavaScript or any other language that will be able to see when the user closes the text file or when the text file is active.For this part of the project, the text file is NOT supposed to be open in another web page. Does anyone know how this could be done?
When someone clicks link in topNavigation frame (the top nav bar), I want 2 things to happen at the same time. A new html page will load into mainContent frame and I want an image to change in rightFrame. Is there a way to make this work?