Load FloatBox in a Parent Window

Page: 1

Author Post

I have two situations, using IE 7.0:

1) Every time that I launch Floatbox, if I have a page named "Default.aspx", page_load event to this page is fired. The page don't appear on the screen. If this page don't exists, it works ok.

2) I report already a situation when closing floatbox and you solve it with same changes on your js files.
In my application I have a page (Page 1) with a child page (Page 2) and this child as an iframe object where I load another page (Page 3).
If I launch FloatBox inside page 3, it works ok but the maximum size I can get is Page 3 dimensions. So, I'm trying to launch FloatBox on Page 1 because this page has IE dimensions and I want to use maximum size I can get.

What I'm doing is this:

On page 1 I'm calling framebox.js:
<script type="text/javascript" src="floatbox/framebox.js"></script>

On page 3 i'm using fb object from page 1:
var page1 = window.parent.parent;
var op='innerBorder:1';
if (ext=='PDF') op+=' ' + 'width: max height: max';

This works like I want, till I close FloatBox.
If I close it with ESC Key, it works ok, but if I close it using the button I get a page showing all my web files in a directory list (if I have a page named 'default.aspx', this page is opened).

Please let me know if I have a different way to do this.

3) I notice that when I Open a PDF inside Floatbox, shortcut ESC don't work. Perhaps is being used by Acrobat viewer.

Best regards
Registered: Aug 2008
Posts: 3382
Hi Quim,
There's a lot here to address. But I'm very interested in your problem #1. This sounds very similar to the issue Stubey was having the this post. Unfortuntately, Stubey couldn't spare the time to pursue that problem, but I'm hoping you can help me track this one down.

If you can, the first thing I would like you to try is to include the new release version from my test site and see if that gives the same trouble. Just replace the floatbox.js and floatbox.css include lines on your affected pages with:
<link rel="stylesheet" type="text/css" href="http://test.randomous.com/floatbox/floatbox.css" />
<script type="text/javascript" src="http://test.randomous.com/floatbox/floatbox.js"></script>

Now if the problem still occurs with the new version code then to make any progress I will need to be able to see the problem on line. If you have somewhere to post a sample of the issue I'll take a look and see if I can see where it is failing. Ideally, that online sample would reference my test instance floatbox code so that I could debug it and narrow in on the code that's giving trouble.

Please let me know if we can pursue these two approaches.

As for your 3 nested documents, here's how it is intended to work. You should include floatbox.js (not framebox.js) and floatbox.css on each of your pages that have floatbox links in them. And if those pages are in nested iframes, all the parent pages should have floatbox included too. When you do this, the fb global var always points to the floatbox instance on the top page. You don't need to set your page1 var, nor reference parent.parent. If your last loaded page does not have floatbox.js included then it will need to use parent.fb to find the floatbox. But wherever floatbox is loaded, you can just use fb directly.

The part about trouble with default.aspx on close sounds like a different variation on the problem in your item #1. I hope we can address that together.

Lastly, a link to a pdf document will be loaded as an iframe. Iframes take over the keyboard handler when they have the focus. Floatbox never sees the keystrokes when the focus is in the iframes window. This is good. Otherwise data entry, navigation, etc., inside a floatboxed iframes might be broken. I can't guarantee the behaviour with pdfs, but generally if you click on the floatbox frame this will bring the focus out of the iframe window and keys like esc etc. will again be handled by floatbox.

Thanks for keeping me in the loop about any problems you are finding.
Hi, thanks for your fast reply, has always.

Your new script solve my first problem :) , now my default.aspx load_page event is not fired when I launch FloatBox. I test it with IE7 and Firefox 2.

About my second problem, even with your new script I still have the problem when closing floatbox.
However, for what I understood, if I only load floatbox.js on Page1, I can reach fb from page3, without referencing window.parent.parent. But the only way to work is using window.parent.parent.fb. I don't know what i'm doing wrong, however, like I said before, floadbox is launched like I want using all the width and Heigh from Page1.
I notice, that if I load framebox.js on Page1 and framebox.js on Page3, if I refer to fb only (inside Page3) I will load floatbox inside Page3, if I refer to window.parent.parent.fb I will load it inside Page1.
However, when I load floatbox.js on Page1 and floatbox.js on Page3, Window.parent.parent.fb works ok, but fb only (Inside Page3) gives me an error saying " 'fb' is undefined".

Another thing that I don't know if it is important. My application is based on Visual Studio 2005 and my Page1 is based in a Master Page. My CSS file is located on MasterPage (this means that it will be used by any page based on that Master Page, however Page1 is the only page using that Master Page), and floatbox.js is loaded on Page1. I already tried to put floatbox.js only on MasterPage, but the result is the same.

Registered: Aug 2008
Posts: 3382
I'm glad one of the problems is solved.

As for the second, without being able to see it in action or get some code to replicate it on my test site, there's not very much I can tell you. If I understand your page hierarchy correctly, you should have floatbox.js included on page 1 and page 2. If you include it on page 3 but not page 2, it will never load there because it's waiting for the page 2 floatbox code to initialize first. If you include floatbox.js on page 1 and 2, you can reference it from page 3 with parent.fb. If you include it on page 3 as well, then you can just use fb from there. If you're using floatbox.js, and not framebox.js, the fb variable will always point to the floatbox loaded on the base page in an iframe hierarchy.

Any chance of me seeing the problem you're having on a test site somewhere???
Registered: Aug 2008
Posts: 3382
With considerable help from Quim, the problem of the close button navigating to a non-existent page looks like it has been solved.

There is a bug in IE7. (I know! I was shocked too!) In some installs, IE7 will ignore return false; in the onclick action of an anchor element. This causes IE to try to load the page referenced in the href attribute of the close link. Since this href is the empty string "", the href refers to either the folder containing the current document or a default document in that folder. The failure could result in a base page refresh, unwanted navigation to a default page, a directory listing, access denied, page not found, or a session re-authentication prompt depending on circumstances.

The fix was to add the following IE-specific code just before return false; in each anchor's onclick action:
if (window.event) event.returnValue = false;

This fix will be included in the minor v3.21 update that will be released this weekend.

Page: 1