Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

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

Open
halukkaramete opened this issue Apr 14, 2022 · 2 comments

Comments

@halukkaramete
Copy link

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 halukkaramete changed the title Using 3. Opening iFrame programmatically. But No hash Using FB V3 & opening an iFrame programmatically. But, the hash is missing! Apr 14, 2022
@fancyapps
Copy link
Owner

fancyapps commented Apr 14, 2022

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.

@halukkaramete
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants