Using a URL Query param is a good option to accomplish this. What we'll do is have a script that checks whether or not the Param exists. I've included code on how to do this. It's all done in javascript.
//This function will check if the current page has the query param of 'video' (or whatever you set it to) & then call your lightbox function.
//Put this in the footer of that page
function checkParam() {
var isVideo = getParameterByName('video');
if(isVideo == 'true') {
//call lightbox open function
}
}
checkParam();
//I'll use this function to get URL query params: http://stackoverflow.com/a/901144/2106563
//This should also go in the footer of the page
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
As for adding a youtube video within your lightbox, it can be done pretty easily with a link similar to this:
href="//www.youtube.com/embed/dQw4w9WgXcQ?feature=player_detailpage&rel=0&autoplay=1
The only part that you need to change between videos is: dQw4w9WgXcQ
. That can be seen in the URL in the browser.
You'll notice that there are Query Params in the URL. One of them is autoplay
. There are a bunch of others too if you wish to customize the link a bit more.