jQuery的的fancybox,iframe或AJAX技术,负载网址负载、网址、技术、fancybox

2023-09-10 14:07:03 作者:十里春风

使用的fancybox(V2),我怎么能创造出独特的网址,一旦负载,显示与iframe的内容的fancybox。我有它伟大的工作与联内容(例如www.mysite.com/index.html#idgoeshere),但不知道是什么网址或JS应包含以装载的fancybox,并在其中,具体的IFRAME或ajax.txt页面。

我试图来实现的,是去一个链接,如:

www.mysite.com/index.html#iframe.html

加载索引页,用的fancybox窗口中打开,并加载到的fancybox窗口iframe.html页面(或者也可以是通过AJAX加载的.txt文件也是如此)。

HTML

 <一类=的fancybox fancybox.iframe的href =iframe.html>的iframe< / A>
 

的fancybox

 <脚本>
$(文件)。就绪(函数($){
    $ .fancybox({
    内容:$(window.location.hash)。html的()
});
    $('。的fancybox)的fancybox()。
});
< / SCRIPT>
 
vba 执行网页javascript JavaScript Ajax jQuery全部知识点,1分钟速懂

感谢您的任何帮助或指导。

凯尔

更新的

感谢大家的帮助!以下是结束了,我伟大的工作。我救了我们我的内容转换成单独的HTML文件,然后叫他们fancybox.iframe

记者:

 <脚本>
$(文件)。就绪(函数(){
    $('。的fancybox')。的fancybox({
     '滚动':'不'
    });
    如果(window.location.hash!==){
        $(window.location.hash)。点击();
    }
});
< / SCRIPT>
 

解决方案

看一看在中的fancybox网站的例子在的fancybox动作链接的href完全根据。所以,如果你加载的页面,然后更新页面上的链接的href指向 iframe.html 之前调用 .fancybox 就可以了,那么它应该工作正常。警告:未经测试code把我的头跟着顶部...

  $(文件)。就绪(函数(){
    $('#目标)ATTR(HREF,window.location.hash.substring(1))的fancybox()。
});
 

该子调用需要删除返回window.location.hash

希望这有助于

With fancybox (v2), how can I create a unique url that, upon load, displays the fancybox with iframe content. I have it working great with inline content (ex. www.mysite.com/index.html#idgoeshere), but don't know what the url or js should contain in order to load the fancybox, and within it, a specific iframe or ajax.txt page.

What I am trying to achieve, is by going to a link like:

www.mysite.com/index.html#iframe.html

Load the index page, with the fancybox window opened, and the iframe.html page loaded into the fancybox window (alternatively it can be a .txt file loaded via ajax too).

HTML

<a class="fancybox fancybox.iframe" href="iframe.html">Iframe</a>

Fancybox

<script>
$(document).ready(function($) { 
    $.fancybox({
    content: $(window.location.hash).html()
});
    $('.fancybox').fancybox();
});
</script>

Thanks for any help or guidance.

Kyle

Update

Thanks for everyones help!! Here is what ended up working great for me. I saved our my content into separate html files and then called them with fancybox.iframe

JS:

<script>
$(document).ready(function () {
    $('.fancybox').fancybox({
     'scrolling'   : 'no'   
    });
    if (window.location.hash !== "") {
        $(window.location.hash).click();
    }
});
</script>

解决方案

Have a look at the examples on the Fancybox site The Fancybox action is based entirely on the href of the link. So, if you load up the page and then update the href of a link on the page to point to iframe.html before calling .fancybox on it, then it should work as expected. Warning: Untested code off the top of my head to follow…

$(document).ready(function(){ 
    $('#target').attr('href', window.location.hash.substring(1)).fancybox();
});

The substring call is needed to remove the # from the hash string returned from window.location.hash

Hope this helps