簡體   English   中英

頁面加載svg上的自動點擊按鈕

[英]Auto click button on page load svg

我想讓腳本在頁面加載時自動單擊視頻圖標按鈕,但是自動單擊不起作用。

碼:

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

自動點擊腳本代碼:

<script type="text/javascript">
document.getElementById("#play-button-shape").click();
</script>

嘗試使用.on("click").trigger("click")函數,它執行相同的操作,但是我的情況與您幾乎相同,並且它已使我解鎖。 我不確定它是否有效,但值得嘗試。

為什么需要在頁面加載時“自動點擊”? 只需在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> 

使用此腳本:

window.onload = function() {
   document.getElementById("play-button").click();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM