Fancy box, grab from url

狂风中的少年 提交于 2019-12-12 01:26:01

问题


I was developing a site and am using bootstrap, and jquery... I found out that bootstrap has modals that is exactly like fancybox, but realized it was not good enough, so I went ahead and got fancybox... I recently saw a website called PrimeDice, and I saw that they were also using fancybox, and I want to setup fancybox, like they did... If you look into their code, you can see that they are getting the fancybox like this...

<a href="/modals/faq.html" class="action-fancybox">faq</a>

Basically what is happening is that if you go to http://primedice.com/modals/faq.html you will see the plain text version of the fancy box. I want to do something similar to this, where it fetches the text or data of the fancybox from a different page... So basically have a folder called modals, and have a file called text.php and then fetch the information from that, and display it as a fancybox on my homepage... I hope you understand what I mean...

This is what their faq code looks like: http://pastie.org/8345073


回答1:


If you have this html

<a href="/modals/faq.html" class="action-fancybox">faq</a>

then use a jQuery code like this

jQuery(document).ready(function($){
    $(".action-fancybox").fancybox({
        type: "iframe"
    });
});

Assuming that you have properly loaded jQuery as well as fancybox js and css files.

See it working in this JSFIDDLE




回答2:


You want to do it with something like that ?

$('.fancybox').click(function(e) {
 e.preventDefault()
 $.fancybox({
   'content': $(this).attr('href'),
   'type':'iframe'
});


来源:https://stackoverflow.com/questions/18938283/fancy-box-grab-from-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!