portwa.blogg.se

Play sound javascript
Play sound javascript





play sound javascript

#PLAY SOUND JAVASCRIPT HOW TO#

You’d have to play around with it and do some research to figure out how to make it actually work for your purpose. The code below is a just an example to illustrate how it would work… Then with JavaScript you could write an onclick event handler to use a function in a script tag to play the sound and redirect after a delay. But this is just for demonstration purposes. Then if you click OK it goes to some other page based on correct or incorrect answer.Īlert popups can be kind of annoying in the real world. Then I have used the play method here to play the audio.

play sound javascript

Then the sound in the 'audio' is linked to the button by the onclick event. Then a global constant of buttons is set. First line I added audio using JavaScript. Then it plays a sound if correct, then pops an alert… correct or incorrect. JavaScript Code: Now play sound on click html has been activated by JavaScript. Then have a button that when pressed, goes to a JavaScript function that checks which radio button is selected. Unless someone else knows a better way to deal with that link problem, my idea is use radio buttons. You would want to stay on the current page (the quiz page) long enough to hear the sound if correct answer was chosen, or a popup or message if wrong answer was chosen, and then be directed to the next page. The problem with using links (anchor tags) is they require an href="" attribute, so as soon as the link is clicked it will go to the next page immediately and you won’t hear the sound. Not sure about doing it in ReactJS because I have not learned it. I think it would be easier to understand how to do it if you have learned these things. Katera barva je v novinarskem svetu "rezervirana" za trace? The right answer is Rumena (in row 30) which is linked to next page (ilona2.html)… So the sound should play when someone clicks on that answer (Rumena) and then go to ilona2.html.

play sound javascript

Thank you for your reply! Can you please describe this more detailed? I pasted my HTML code below.







Play sound javascript