The example in this article describes how JS obtains the youtube key from the connection. Share it with everyone for your reference. The specific analysis is as follows:
This code demonstrates how to intercept a substring from a string
// Example link: // <a id="myLink" href="http://www.youtube.com/watch?v=cyRqR56aCKc&feature=PlayList&p=00000000000&index=0&playnext=1">Youtube link</a> var youtubeLink = document.getElementById('myLink').href; var youtubeVideoKey = youtubeLink.substr(youtubeLink.lastIndexOf("v=") + 2, 11); // youtubeVideoKey will return "cyRqR56aCKc"
I hope this article will be helpful to everyone’s JavaScript programming design.