Home  >  Article  >  Web Front-end  >  JS implements obtaining the key instance of youtube from the connection_javascript skills

JS implements obtaining the key instance of youtube from the connection_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:52:011488browse

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&#63;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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn