简体   繁体   English

如何将URL更改为fancybox内部URL

[英]how to change url to be as fancybox inner url

Im useing facybox 2.1.5 to show an iframe , and i need the url 我正在使用facybox 2.1.5显示一个iframe ,我需要url
be same as the url inside fancybox, which need to be dynamic. 与fancybox中的url相同,它必须是动态的。

For example, if i open www.wikipedia.com in fancybox my url should be www.wikipedia.com , and if in wikipedia i will click some other link my url has to change properly without refreshing the page ( www.wikipedia.com/something ). 例如,如果我在fancybox中打开www.wikipedia.com ,则我的url应为www.wikipedia.com ,如果在Wikipedia中,我将单击其他一些链接,而我的url必须正确更改而不刷新页面( www.wikipedia.com/something )。

Update , and when i will close the fancybox my url will back to normal. 更新 ,当我关闭fancybox时,我的网址将恢复正常。

**Assume, in wikipedia the url and the content is changing witheout refreshing ( ajax ). **假设,在Wikipedia中, url和内容在不断变化而没有刷新( ajax )。

Here some code of mine: 这是我的一些代码:

          $('.fancybox').fancybox
          ({
                type: "iframe",
                padding: 0,
                fitToView: false,
                autoSize: false,
                 'scrolling'   : 'no',
                wrapCSS: 'fancybox-custom',
                closeClick: true,
                openEffect: 'none',
                helpers: 
                   {
                    title: {
                        type: 'inside'
                           },
                    overlay: 
                             {
                        css: 
                         {
                            'background': 'rgba(238,238,238,0.85)'
                         }
                             }
                    },

               beforeShow: function () 
                {
                  this.width = '60%'; 
                    this.height = ($('.fancybox-iframe').contents().find('body').height()) + 500;
                }

            });

document.getElementById("FrameID").src This function can be used to get the url out of an i-frame. document.getElementById("FrameID").src此函数可用于从i框架获取URL。 you can update your url with value returned by this function. 您可以使用此函数返回的值更新网址。

you can use change of url returned by the function as a trigger 您可以将函数返回的网址更改用作触发器

var _url
_url = document.getElementById("FrameID").src;
function do(){
   if(_url != document.getElementById("FrameID").src){
        //update url here
   }
   setTimeOut("do()",1000);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM