[Solved] HTML button to play video causing unwanted refresh

0

I have video elements included in my Text/Instructions  (I cannot use the inbuilt video player because I am filling the src dynamically with Javascript), and I want to restrict the controls that my users have. Therefore I have made a “Play” button with the following code:

<video  src=””  id=’ve1′></video>
<button onclick=”document.getElementById(‘ve1’).play()”>Play video 1</button>

However, when I click the button, the video begins to play for around a second then the page refreshes. This  refresh behaviour only happen within the survey environment. How can I stop this automatic refresh behaviour?

Thanks for your help!

kristypjames asked

    Best answer

    0

    Found the solution: Add type=”button” into the HTML tag. Eg:

    <video  src=””  id=’ve1′></video>
    <button type=”button” onclick=”document.getElementById(‘ve1’).play()”>Play video 1</button>

    kristypjames answered
      ×

      Login

      Question stats

      • Active
      • Views239 times
      • Answers1 answer
      • Followers0 followers