Quantcast
Channel: DeveloperFeed » Javascript
Viewing all articles
Browse latest Browse all 5

How to get video id from a Youtube url in Javascript?

$
0
0
Snippet e.g. if the youtube, video url is: http://www.youtube.com/watch?v=xptDCPlSSfI& The snippet will return xptDCPlSSfI var url = “http://www.youtube.com/watch?v=xptDCPlSSfI”; var video_id = url.split(‘v=’)[1]; var ampersandPosition = video_id.indexOf(‘&’); if(ampersandPosition != -1) { video_id = video_id.substring(0, ampersandPosition); }

Viewing all articles
Browse latest Browse all 5

Trending Articles