0

I have a file with a story Demo story. When I move to the next page, I am using the right arrow key. The old page continues playing while I am in the new page and I need to hear the new record.

  1. How can I create an event or make another solution when I go to the next page to stop the old playing?

I am still in the same file when I go to the next page.

<footer>
    <div style="position:relative;width:100%;margin-top:0px;margin-bottom:0px;">
    <div style="width:960px;height:94px;position:relative;margin:0px;margin-left:auto;margin-right:auto;margin-top:5px;margin-bottom:5px;padding:0px;overflow:hidden">
        <audio controls="controls">
          <source src="CarlyAndHerLemons1.ogg" type="audio/ogg" />
          <source src="CarlyAndHerLemons1.mp3" type="audio/mpeg" />
        </audio>
</footer>

I think I should use by code similar to document.getElementById('demo').pause()

Many thanks.

1
  • Could you possibly post a simplified demo to JS Fiddle, where it's easier for us to tinker with, and adapt, your code? Otherwise we're left trying to make changes using the dev console (or building our own versions of your page) which is possible, it's just far more difficult than it needs to be. Please, help us to help you. Commented Aug 12, 2012 at 15:51

1 Answer 1

1

Give your audio tag an ID and then use:

document.getElementById('yourAudioTagID').pause();

Also this page might be useful.


Edit:

Here is a JSFiddle Demo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.