如何链接到javascript弹出窗口

How to link to a javascript popup

本文关键字:javascript 窗口 何链接 链接      更新时间:2023-09-26

我有一个带有mediabox的网站,mediabox是一个javascript,可以弹出元素并将其发送到Youtube链接。现在我想链接到弹出窗口,这可能吗?

我想链接到我网站上的弹出窗口,这样他们就可以观看我链接到那里的电影。。。

问候,

您可以使用url参数来实现这一点。例如,指向您的网站的链接可能类似于:www.mysite.com/something?video_url=<some youtube link>。然后,在您的页面上,您可以有事件处理程序($(document).ready(function(){...})),它将检查url中是否存在"video_url"参数,以及它是否只是显示加载了<some youtube link>的弹出窗口。例如(此处找到getParameterByName(name)):

// a function that gets the value of query parameter
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, " "));
}
// jquery used, but not really needed
$(document).ready(function() {
    var video_url = getParameterByName("video_url");
    // your function that shows the popup
    showPopup(video_url);
});

想要在Mediabox中打开的任何对象,只需在标记中添加rel="mediabox[width height]"即可。简单!

  <a href="http://www.youtube.com/view_play_list?p=63F0C78739B09958" rel="lightbox[social]" 
title="www.youtube.com playlist::hover over the window to see everything in the play queue">
    YouTube Playlist »</a>

供参考

官方网站