Last active
December 27, 2015 08:39
-
-
Save AmrEldib/7297410 to your computer and use it in GitHub Desktop.
Bookmark to Open YouTube Video in Popup Window
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
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