parent.fb is undefined

Page: 1

Author Post
Member
Registered: Nov 2008
Posts: 28
Haven't been here for awhile ... glad to see you are still in business!

Page 1 has a button on it. At the end of the file it has the following code:

----------------------------------------------------------------------------
</html>

<% If Session("AddToCartMsg") <> "" Then %>
<script language="javascript">AddTocartNow()</script>
<%
End If
Session("AddToCartMsg") = ""
%>
-----------------------------------------------------------------------------

The javascript AddToCartNow() is:

-----------------------------------------------------------------------------
function AddToCartNow()
{
TheHref="m_orderFundraisingAddToCart_popup_14.asp"
TheRev="width:380 height:500 scrolling:yes"
TheTitle=""
parent.fb.loadAnchor(TheHref,TheRev,TheTitle)
}
-----------------------------------------------------------------------------

So, when the user presses the button on Page 1, Page 2 is loaded. Some calculations and database stuff occurs on Page2, TheAddToCartMsg is set and the user is redirected back to Page 1.

Page 1 does it thing and tries to execute the AddToCartNow() function and that is where the error occurs.

I am doing this convoluted coding because I want the user to have options other than OK or Cancel when the AddToCartMessage is displayed.

By the way, other floatbox calls just like the one above work just fine on Page 1.

Thank you in advance for your help,

--Fred
Administrator
Registered: Aug 2008
Posts: 3382
Hi. Welcome back.

I can't sort out problems by picking through code snippets. I've almost never identified the cause of a real-world problem by viewing quoted code, and things usually go quickly down rabbit holes when I try. You have to show me the live page with the problem on it if I am to determine the reason for the problem.

FYI, fb.loadAnchor is an ancient and deprecated function from ancient and deprecated Floatbox releases. It was replaced in version 3.50 with fb.start, 5.2 years ago.

I will go out on a limb without seeing the page and say that if you truly are getting a debug message of "parent.fb is undefined", it can only be because fb is not defined - that is, the floatbox software is not running - on the parent page.
Member
Registered: Nov 2008
Posts: 28
I apologize for the older version of floatbox. I I wrote this code quite awhile ago and it has worked nicely which is a testament to your product.

Here's how you can see what is happening:

1) go to http://www.floridaindianrivergroves.com
2) click on the "order now" button (lower left)
3) enter 205241 as the organization id and click on "shop" button
4) click on the large green button with person unloading a truck

This is Page 1

5) click on "view details" under the picture of navel oranges. This displays a brief description in a floatbox window.

6) click on "add to cart" link under the picture of the navel oranges. This actually goes to another page (Page 2) which does some calculations etc, set the Session("AddToCartMsg") variable and redirects back to Page 1

7) At the end of the code in Page 1, if Session("AddToCartMsg") <> "" it calls a javascript function which displays the message and then is supposed to display a floatbox window. This is where the error occurs.

Thanks,

Fred
Administrator
Registered: Aug 2008
Posts: 3382
I don't think I can provide any meaningful help here. The setup is just too unstructured to do any rational debugging in, and I can't trace the timings and sequencing of the logic flow through the jumps back and forth between pages.

A possibility is that you are calling fb.loadAnchor immediately upon page load prior to the fb variable being instantiated. If I recall correctly in that ancient Floatbox version the fb object gets defined when core.js loads, and core.js lazy loads after the document completes. If you call loadAnchor right at page load time, you might be calling it before it exists. Version 3.54 introduced an "afterFBLoaded" callback that you could hook things like loadAnchor at startup to, but you're using 3.53. It's possible that you can't do what you want to do with that old version.

This speculation about loadAnchor being called before Floatbox has fully loaded is just a wild guess though, and just one example of a reason why fb might be undefined. You're going to have to sort out the page code yourself. It's not a Floatbox failing and so lies outside the realm of Floatbox support. And if it was a Floatbox failing, the first thing I would need you to do would be to update to the current version and work with that.

By the way, there's no reason to be referencing "parent" if you're not calling between frames in an iframe or frameset hierarchy, and I don't see any signs of frames on your pages.
Member
Registered: Nov 2008
Posts: 28
Sorry it has taken so long to get back to you.

I am now loading floatbox version 424 for that page. How might I implement the afterFBLoaded function in that code?

function AddToCartNow()
{
alert ("1 Navel Oranges - 10 Pound Carton - 16 to 18 Pieces has been added to your shopping cart.")

TheHref="m_orderFundraisingAddToCart_popup_14.asp"
TheRev="width:380 height:500 scrolling:yes"
TheTitle=""
parent.fb.loadAnchor(TheHref,TheRev,TheTitle)

Thanks,
--Fred
Administrator
Registered: Aug 2008
Posts: 3382
Very strange that you would 'update' to the 3 year old version 4.24 instead of to the latest and greatest version 6.0.3. There's been a tremendous amount of good stuff that's gone into the updates, including lots of bug fixes and stability improvements, much better support for mobile devices, modern video, and a whack of other goodness. Is there a problem with the later releases that I should know about and that has discouraged you from updating to the current?

In general, you should check the documentation, including the API and Options references, that's bundled with whatever version of Floatbox you're using to determine the programming capabilities and syntax of that version.

fb.start could be fired from the afterFBLoaded callback in version 4.24 with something along the lines of ...
<script>
fbPageOptions = {
afterFBLoaded: function () {
fb.start( &#039;myPage.asp&#039;, &#039;width:380 height:500&#039; );
}
};
</script>

But using afterFBLoaded to auto-start something at page load time is not optimal. Better to just use the autoStart option on a standard floatboxed link.
<a class="floatbox" href="myPage.asp" data-fb-options="autoStart:true width:380 height:500"></a>
Member
Registered: Nov 2008
Posts: 28
Thank you. Your suggestions worked great.

To be honest, I wrote these web pages a few years ago and it was just now that I was asked to make a change and floatbox turned out to be best way to make that change.

I would not mind upgrading to the latest version of floatbox if I was certain that all of my "old" code would perform without modification.

Thanks again. You have the best customer support of any product/utility that I use.

--Fred

Page: 1