使用URL查询参数是一个很好的选择。我们要做的是有一个脚本来检查Param是否存在。我已经包含了如何做到这一点的代码。这一切都在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, " "));
}
至于加入您的收藏夹中的YouTube视频,它可以很容易地与这个类似的链接来完成:
href="//www.youtube.com/embed/dQw4w9WgXcQ?feature=player_detailpage&rel=0&autoplay=1
,你需要视频之间改变的唯一部分是:dQw4w9WgXcQ
。这可以在浏览器的URL中看到。
您会注意到URL中有查询参数。其中之一是autoplay
。如果你想自定义链接,还有其他一些其他的。
我在昨天下面发布了一个答案。这是你在找什么? – EnigmaRM 2015-02-11 15:23:00