I have a youtube video open on my browser. How to go to specific time stamp using javascript? I want to use this in chrome extension. I can give the t query in url but it reloads the whole page. I don't want to reload the whole page. Help me with this. Thanks
Asked
Active
Viewed 978 times
3
-
Write a [content script](https://developer.chrome.com/extensions/content_scripts) that finds the `video` element and sets its `currentTime`. – wOxxOm Apr 20 '21 at 12:36
-
Does this answer your question? [Change the current YouTube video time without using YouTube API](https://stackoverflow.com/questions/69919978/change-the-current-youtube-video-time-without-using-youtube-api) – Stéphane Bruckert Feb 16 '23 at 11:17
1 Answers
3
Try the player.seekTo(seconds:Number, allowSeekAhead:Boolean)
function:
document.getElementById("movie_player").seekTo(seconds,true);
Resources :https://developers.google.com/youtube/iframe_api_reference?csw=1#Playback_controls
credit to this answer for getting the player element

ATP
- 2,939
- 4
- 13
- 34
-
We can even use document.getElementById("movie_player").Currentime=seconds – sandeysh May 04 '21 at 07:31
-
1@sandeysh Nope. it doesn't work. it only changes the variable Currentime it doesn't update the UI – ATP May 04 '21 at 15:56