Close FB window and load URL in parent

Page: 1

Author Post
gregp
Guest
Hi,

I want to pop up a FB window containing some links, and when users click on the links I want to close the FB window and navigate to a URL in the parent specific to the link they clicked on. I know there's something in the options about loadPageOnClose and I think this would be OK if I wanted to close the FB window via the close button and then load a URL; but I want the FB window to close via clicking the links within the FB and then move to a URL in the parent depending which link in the FB window they clicked.

E.g.
<fbwindow>
<a href="link1.html">Click me to close this window and go to page 1</a>
<a href="link2.html">Click me to close this window and go to page 2</a>
</fbwindow>

I'm sure it's easy but I can't see how it's done...

Help please,
Greg
Administrator
Registered: Aug 2008
Posts: 3382
From your fb content page:
<a href="somePage.html" onclick="parent.fb.loadPageOnClose = this.href; parent.fb.end(); return false;">click me</a>
(or similar click action on another element type).
gregp
Guest
Perfect, thanks. Out of interest was this in the doco and I just missed it? There's no way in the world I could have figured that out myself!
Administrator
Registered: Aug 2008
Posts: 3382
Yes, both loadPageOnClose and end() are documented in the API Reference.

The loadPageOnClose entry says in part "loadPageOnClose can be quite useful in programming active floatbox content, specifically, for refreshing the base page or navigating to a new page on floatbox exit".

The entry for the end() function tells folks to "call fb.end() to close a running floatbox."

Use of "parent.fb" is also discussed with the following:
An iframe displayed by floatbox that does not have floatbox.js included on its document will not have the global fb var in its window's scope. To programmatically use fb from such a child iframe, fetch it from the parent window by referring to it as "parent.fb".
Member
Registered: Feb 2015
Posts: 4
And what do I do if the links are contained in a PDF file (generated by a Word file) that is being displayed in Floatbox?

I don't think I can add any onclick event to hyperlinks in Word, and I haven't managed to do so within the PDF either. Is there a way to instead tell Floatbox, it should close itself whenever a link is activated from inside the PDF?
Administrator
Registered: Aug 2008
Posts: 3382
I doubt it. Floatbox is javascript running in the context of a web browser presenting an HTML document. I don't know of any way to hook it in to other applications or document types.

Page: 1