Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Fancybox, how can I open a link in the parent window (& close the Fancy Box)?

I'm using Fancybox to open a pop-up that allows the user to choose between two different methods of logging on to a site. I'd like clicking either of the links in the Fancybox to close the fancybox and open the link back in the parent web page.

Is this possible?

Here's how I'm opening the FancyBox box:

         $("#logonChooser").click(function () {
             $.fancybox.open({
                 href: 'LogonChooser.html',
                 type: 'iframe',
                 padding: 5
             });
         });

Here's the LogonChooser.html:

<head>LogonChooser.hmtl</head>
<body>
  <a href="LogInDatabase.html">Log In</a>
  <a href="LogInFacebook.html">Log In Facebook</a>
</body>

I can close the fancybox like so:

<a href="LogInDatabase.html" onclick="parent.$.fancybox.close();">Log In</a>

but I don't get the link back in the parent page.I'd like clicking on either of the links to close the fancybox and open the link in the page that spawned the fancybox, rather than inside the fancybox.

Any help is appreciated. I'm using Fancybox 2 if that helps, but am open to using the previous version if that is easier.

like image 373
Hairgami_Master Avatar asked Feb 21 '23 09:02

Hairgami_Master


1 Answers

It should be sufficient when you add this to the links:

target="_parent"

The linked page now will be opened in the parent page, no need to close the fancybox, because the fancybox will be replaced(it's also a part of the parent page)

like image 173
Dr.Molle Avatar answered May 13 '23 10:05

Dr.Molle