Search code examples
iframehyperlinkfancybox

How can I open fancybox links in same window?


I've searched around everywhere and I can't find any insight to my question. I'm using fancybox to show an iframe on the page that is just a smaller html file. There is one link in the fancybox iframe and when you click it, the page opens inside the iframe. How do I make it so the link opens in the current window. I can get the link to open in a new window with "_blank" but I want it to open in the current. Any ideas?

My js code for the action is:

$("#hours").fancybox({
'width'             : 980,
'height'            : 540,
'autoScale'         : false,
'transitionIn'      : 'elastic',
'transitionOut'     : 'elastic',
'type'              : 'iframe'
});

HTML of the link to open the iframe is simply:

<a class="top" id="hours" href="hours.html">Hours</a>

The HTML of the link inside the iframe is just a basic link as well so I'm pretty sure I am not doing anything to influence this and opening in the iframe is just a default.


Solution

  • have you tried javascript? since you are in an iframe. maybe something like this within the iframe/fancybox.

    <a href="#" onclick="javascript: self.parent.location='page.htm';">Click</a>