javascript ajax/jquery - 打开简单弹出窗口的脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14414588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:35:26  来源:igfitidea点击:

ajax/jquery - Script that open simple popup window

javascriptjqueryajaxpopupwindow

提问by Godfazzer

I need script that opens a popup window, like lightbox. but not with image

我需要打开一个弹出窗口的脚本,比如灯箱。但不是图像

It must load video player code, from html file, and send video file ID to this code

它必须从 html 文件加载视频播放器代码,并将视频文件 ID 发送到此代码

Player code in html:

html中的播放器代码:

<iframe src="http://site.com/embed/video file ID" style="width: 800px; height: 450px; border: none; background-color: #000;" frameborder="0"></iframe>

So i need script to open popup window with code above.

所以我需要脚本来打开带有上面代码的弹出窗口。

Thanks!

谢谢!

回答by Paul Fleming

Fancyboxdoes this really well. Version one is free to use.

Fancybox在这方面做得很好。第一版免费使用。

Html:

网址:

<a class="forpopup" href="http://www.example?iframe">This goes to iframe</a>

JS:

JS:

$('a.forpopup').fancybox();

回答by user1983902

See in jQuery ColorBox, in Demos Pagefind the Other Content Typessection for outside HTML content via AJAX, Flash and video examples.

请参阅jQuery ColorBox,在演示页面中通过 AJAX、Flash 和视频示例找到外部 HTML 内容的其他内容类型部分。

A brief example of usage:

一个简单的用法示例:

// Format:
$(selector).colorbox({key:value, key:value, key:value});

// Examples:
// Image links displayed as a group
$('a.gallery').colorbox({rel:'gal'});

// Ajax
$('a#login').colorbox();

// Called directly, without assignment to an element:
$.colorbox({href:"thankyou.html"});

// Called directly with HTML
$.colorbox({html:"<h1>Welcome</h1>"});

// ColorBox can accept a function in place of a static value:
$("a.gallery").colorbox({rel: 'gal', title: function(){
    var url = $(this).attr('href');
    return '<a href="' + url + '" target="_blank">Open In New Window</a>';
}});