Event Occurs When Youtube iframe Seeker Clicks

Asked 1 years ago, Updated 1 years ago, 38 views

I wrote the following code because I wanted to create an event when I clicked on the seek bar in a scene like the image, but it doesn't work well.
Is there a way to generate an event when clicking Seekbar?

$(function(){
    $(".ytp-progress-bar-padding").click(function(){
        console.log("----")
    });
});

Image 1

javascript jquery

2022-09-30 15:51

1 Answers

Since it's in iFrame, I think the way it's written is to specify the tag in iframe

If you want to read tags in iframe, you will need to do the following.
https://teratail.com/questions/40316

$(window).on("load", function(e){
  $("#iframe").contents().find("body").on("click", function(e){
    console.log("click");
  });
});

Also, if you want to work in conjunction with YouTube actions when you move the seek bar, etc.
I think it is common to use api.
I don't know if I can use it in this case, but please consider it.
https://so-zou.jp/web-app/tech/web-api/google/youtube/player-api/iframe.htm#status


2022-09-30 15:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.