Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 15:52:01
Original
1488 people have browsed it

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"

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!