Retrieving current URL from Shadowbox on close

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieving current URL from Shadowbox on close

mmashburn
I have a Shadowbox that displays an external website.  The user can then navigate anywhere they want on that site, then when they close the shadowbox, I need to retrieve the final URL that they were on.  Does anyone know how to do this?

thank you in advance!

Reply | Threaded
Open this post in threaded view
|

Re: Retrieving current URL from Shadowbox on close

mmashburn
this is kind of what I was thinking, but im not sure where to go from here:

 
<script type="text/javascript">
        function getURL(originalLink) {
            Shadowbox.open({
                player: "iframe",
                content: originalLink,
                options:
                {
                    onClose: function () 
                    {
                        //add code here to get new link?
                    }
                }
            });
        }
    </script>
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving current URL from Shadowbox on close

arttronics
The markup you provided is looking good for your idea.

This POST contains a method for the old version of Shadowbox, but you can adapt that method for your function use.

Post back your working function to share with others if you can.

When posting your markup here on the forum follow these simple steps:

0. Login and paste your markup into the Message Box.
1. Mouse select the markup you just pasted.
2. Press the More Button from the Message Box Toolbar.
3. Select Raw text from the drop down menu. DONE!

If I don't respond to your POST, it's your inability to provide your markup correctly.

Check out a few DEMOS I made that are here in this forum.

Reply | Threaded
Open this post in threaded view
|

Re: Retrieving current URL from Shadowbox on close

mmashburn
 <script type="text/javascript">
        function getChildURL(link) {
            Shadowbox.open({
                player: "iframe",
                content: link,
                options:
                {
                    beforeClose: function () {
                        try { alert(document.getElementById('sb-player').contentWindow.location.href); }
                        catch (err) {alert(err);}
                    }
                }
            });
        }
    </script>

I was able to add my own custom option to the shadowbox.js file that runs before the 'onClose' function runs, so I can grab the 'href' property from the shadowbox player right before it is closed.   You then just reference that new option in your shadowbox.open or shadowbox.init statement like normal (shown above in example). If anyone needs the other code inside the .js file, just let me know and I can post that too..

The only catch is that it will not work if the link you are returning from shadowbox is on a different domain that the parent window.  It will give you a permission denied error for security reasons (cross-domain policy?).  

Does anyone know a way around this?
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving current URL from Shadowbox on close

Cubix Web Solutions
Can you please post the beforeClose function that you used inside shadowbox.js? Thanks