Created
July 3, 2019 05:56
-
-
Save aaryadev/c60fb662b0c99052770c7184e517d469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getId(url) { | |
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; | |
var match = url.match(regExp); | |
if (match && match[2].length == 11) { | |
return match[2]; | |
} else { | |
return 'error'; | |
} | |
} | |
var videoId = getId('http://www.youtube.com/watch?v=zbYf5_S7oJo'); | |
var iframeMarkup = '<iframe width="560" height="315" src="//www.youtube.com/embed/' | |
+ videoId + '" frameborder="0" allowfullscreen></iframe>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment