fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

Using FB V3 & opening an iFrame programmatically. But, the hash is missing!

Open halukkaramete opened this issue 2 years ago • 2 comments

Hello...

When I open a iframe URL thru litebox programmatically ( with the basic code below), hash does not change.

I'd like the hast to be part of the URL, just like the normal hrefs with data attributes automatically do.

The reason I like this is because when you load a page with that URL ( with the hash ),as soon as the browser loads the main URL, your code kicks in and fires up the litebox of that iframed URL

But when I open my lightbox thru this code, this functionality is missing in action.

$.fancybox.open({
                type: 'iframe',
                src:url,
                opts : {
                    afterClose : function( instance, current ) {
                        $('.closerX').css('visibility', 'visible');
                    },
                    afterLoad : function( instance, current ) {
                        $("body").css("cursor", "default");
                    }
                }
            });

Is there a way to add the hash programmatically into the above code so I can enjoy the same functionality?

Thank you

halukkaramete avatar Apr 14 '22 08:04 halukkaramete

Hi,

This feature is available in v4, but I honestly do not remember about v3. I think it was not fully implemented. You can try to pass hash option, like opts : { hash : "aaa" }. I think that for full functionality you would have to check URL hash on start to see if Fancybox should start, and you would also have to watch URL hash change to see if you have to open/close Fancybox.

fancyapps avatar Apr 14 '22 13:04 fancyapps

I think a custom solution can be developed, each hash acts as a key to map to a specific URL, and when Dom loads and onReady we can check the window.location.hash, and if there is a hash to be acted upon, we simply act upon by firing the same iframe FB programmatic call that popped that lightbox in the first place.

halukkaramete avatar Apr 14 '22 18:04 halukkaramete