0

I want to make a script auto click on video icon button on page loading, but auto click is not working.

Code:

  <svg class="button" id="play-button">
  <use xlink:href="#play-button-shape">
 </svg>

Auto click script code:

<script type="text/javascript">
document.getElementById("#play-button-shape").click();
</script>
DavidG
  • 24,279
  • 14
  • 89
  • 82
Masud Rana
  • 51
  • 8

3 Answers3

1

Try the .on("click") or .trigger("click") function, it does the same thing but I had pretty much the same case as you and it had unlocked me. I'm not sure it works but it's worth trying.

Alix Eisenhardt
  • 313
  • 2
  • 10
0

Why would you need to "autoclick" on page load? Just use a <video> element with autoplay...

<video controls autoplay>
  <source src="http://mirror.cessen.com/blender.org/peach/trailer/trailer_400p.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
Badacadabra
  • 8,043
  • 7
  • 28
  • 49
0

Use this script:

window.onload = function() {
   document.getElementById("play-button").click();
}
Majid Parvin
  • 4,499
  • 5
  • 29
  • 47