Skip to content

Instantly share code, notes, and snippets.

@AmrEldib
Last active December 27, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmrEldib/7297410 to your computer and use it in GitHub Desktop.
Save AmrEldib/7297410 to your computer and use it in GitHub Desktop.
Bookmark to Open YouTube Video in Popup Window
javascript:(function()
{
var url = window.location;
if(url.origin.indexOf("www.youtube.com") == -1)
{
alert("Sorry, this is not a YouTube page! URL: " + url.href);
}
else
{
var width = "width=" + 600;
var height = "height=" + 480;
var left = "left=" + (screen.width - width)/2;
var top = "top=" + (screen.height - height)/2;
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == "v") {
var videoId = pair[1];
}
}
window.open("http://www.youtube.com/embed/" + videoId, document.title, "location=no, directories=no, menubar=no, toolbar=no, scrollbars=no, status=no, resizable=yes, " + width + ", " + height + ", " + left + ", " + top );
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment