[英]Auto click button on page load svg
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>
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. 尝试使用
.on("click")
或.trigger("click")
函数,它执行相同的操作,但是我的情况与您几乎相同,并且它已使我解锁。 I'm not sure it works but it's worth trying. 我不确定它是否有效,但值得尝试。
Why would you need to "autoclick" on page load? 为什么需要在页面加载时“自动点击”? Just use a
<video>
element with autoplay
... 只需在
autoplay
使用<video>
元素即可...
<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>
Use this script: 使用此脚本:
window.onload = function() {
document.getElementById("play-button").click();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.