将 HTML 页面作为内容放置在 JQuery Fancybox 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9378572/
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-08-27 10:43:00  来源:igfitidea点击:

Placing HTML page as content within JQuery Fancybox

jqueryfancybox

提问by Kuldip Raj

I am using Fancybox. http://fancybox.net

我正在使用 Fancybox。http://fancybox.net

The problem I am having is in passing an HTML page as content into Fancybox. I see the link options, but not sure how to pass HTML. Can anybody help me out?

我遇到的问题是将 HTML 页面作为内容传递到 Fancybox。我看到链接选项,但不确定如何传递 HTML。有人可以帮我吗?

------- Adding code below

function test() {
    $.fancybox($.extend(fancyboxdefaults(), {
        wrapCSS: 'default',
        'content': 'static/common_structure.html',
        'afterShow' : function () {
            $("h2").html('Thank you');
            $("p").html('Thank you for your response.');
        }
    }) );
    return false;
}

回答by Todd Moses

The documentation page http://fancybox.net/howtois pretty good and explaining how to use it.

文档页面http://fancybox.net/howto非常好并解释了如何使用它。

If you mean displaying HTML in a Fancybox then this will work:

如果您的意思是在 Fancybox 中显示 HTML,那么这将起作用:

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

or

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

If you want to create HTML to be passed to it then the following should work:

如果您想创建要传递给它的 HTML,那么以下应该起作用:

$('#my_page').fancybox({ 
        'scrolling'     : 'no',
        'overlayOpacity': 0.1,
        'showCloseButton'   : false,
        'content' : '<p>your html here</p>'
    });

回答by Majid Shahmohammadi

You can work with fancybox Ajax or Iframe and load your HTML page into box.

您可以使用fancybox Ajax 或Iframe 并将您的HTML 页面加载到框中。