Launch floatbox window w/o click?

Page: 1

Author Post
Strahan
Guest
Can you create a floatbox without having to tie it to a link? Thanks!
Administrator
Registered: Aug 2008
Posts: 3382
Yes. Please see fb.start() in the API reference.
Strahan
Guest
Thanks!
Strahan
Guest
Sorry for being thick headed, but I added this to my javascript block:

fb.start({ href:'index.php?mode=showdialog', rev:'theme:custom width:430 height:180 scrolling:no', title:'test' });

and I got the following error:

Error: a.revOptions is undefined
Source File: /floatbox/floatbox.js
Line: 478

It has the rev: in there, so I'm not sure what it's complaining about...?

PS, I just downloaded the latest FB and installed on my server, still the same issue.
« Last edit by Unknown on Wed Apr 22, 2009 10:21 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
I panicked (mildly) when I read your post as it sounds like a serious floatbox bug (heaven forbid!). Then I relaxed when I realized there is no "a.revOptions" in the current version 3.50 of floatbox. You must be using an earlier version. In that case, use fb.loadAnchor('index.php?mode=showdialog', 'theme:custom width:430 height:180 scrolling:no', 'test');

And you'll need to use the instructions that were included in the docs folder in your zip file. The online instructions are for the latest version.

That fb.loadAnchor call will work in both versions, but I lean towards using fb.start in the new version because its function name more clearly matches the action being taken.
Strahan
Guest
Weird. I was afraid of an old version mismatch, so I went to my web server root and renamed /floatbox to /floatbox.org then downloaded floatbox_350.zip and unzipped it and put the unzipped floatbox stuff back as /floatbox.

So, it really shouldn't have referenced that at all right? Well, I'll give it a whirl with the other syntax you gave, thanks for the help!
Administrator
Registered: Aug 2008
Posts: 3382
Weird indeed. If it keeps being weird, I'd really appreciate an online link that I could peer in to.

Sounds like a probable cacheing problem. (Pulling the old version from the browser cache)
« Last edit by admin on Wed Apr 22, 2009 10:55 pm. »
Strahan
Guest
OK, that did the trick! (sorta hehe)

In Firefox, everything is perfect. However in IE, when the code fires it says:

'fb' is null or is not an object

On the same page I have a "Login" link that is built like this:

if (empty($Username)) Write("<a href='index.php?mode=login' rel=floatbox rev='loadPageOnClose:self theme:custom width:430 height:180 scrolling:no'>Login</a>");

..and that works fine whilst the automatic one doesn't. Ugh.
Administrator
Registered: Aug 2008
Posts: 3382
Maybe you're trying to fire fb.start prior to fb being initialized. If you're doing it from inline code in the body, that's probably the case. Floatbox initializes after the DOM has finished being built, but inline code fires while the DOM is being built.

To launch floatbox from code, it needs to be in response to an event after the page has loaded. (window.onload will do just fine.) But if all you're trying to do is launch something at page start, use the autoStart option instead.

Or I am I way off base here?
Strahan
Guest
Ahh, I think autostart was the key. That seems to be working great! That is, once I got past the mistake of having the system forced to run the code each time rather than only when the cookie is missing, made for a nice cascading window effect lol.

Thanks ALOT for the help, I really appreciate it!
« Last edit by Unknown on Wed Apr 22, 2009 11:08 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
I think the order of events is a crap shoot when using body.onload. Floatbox might get there first, or that code might fire first. And I think you can get different orders from different browsers. Your experience would tend to confirm this. Yeah, you want autoStart for sure.

No offence intended, but you sound like a person who has not read the docs. If so, it can be a real time saver to do so. ;)
Strahan
Guest
Guilty as charged, heh. I skimmed, and it bit me in the butt. I intend to grab some cherry pie, a big glass of iced tea and spend some quality time with the docs now ;)

Thanks again, sorry for the newbishness hehe.
Member
Registered: Apr 2009
Posts: 52
Location: Everett, WA
Having just recently upgraded to the newest version of FB (3.5.1), I'm getting the 'fb' is null or not an object in IE7 as well.

My site looks to a database to determine if there are any alerts the user needs to see and if so, writes code similar to the following near the bottom of the page:

showAlertsystem_alerts = function() {
fb.loadAnchor('/alerts.ncf?ajax=true&alertid=281&random=' + Math.random(),'showClose:true;width:500px;height:300px;','System Alerts');
}

var listener = addEvent( window, 'load', function() { showAlertsystem_alerts(); }, false );

The addEvent function just determines the best method for attaching the event (ie vs everyone else)...

Works very well in all but IE now. :( If I do a CTRL-SHIFT reload on the page, it does fire fine I've noticed.

I see that you've now implemented a "autoStart:true" feature for anchor tags revs... should I be using this instead somehow?

-b
« Last edit by PsychProd on Fri May 01, 2009 7:20 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
It sounds like we've got a race to the finish line here with the window.onload equivalent action firing before the floatbox object has initialized. I'm surprised. My expectation is that fb is present when window.onload fires, but your evidence points to the contrary.

There's a couple of alternate approaches that should work. One uses autoStart that you alluded to (which incidently has been around in floatbox versions for a long time).

What if, instead of writing the alerts function and onload event, your page simply wrote an autoStart anchor. Something like:
<a href="alerts.ncf?ajax=true&alertid=281" class="floatbox" rev="autoStart:true width:500 height:300 caption:`System Alerts`"></a>


The second approach is probably not as robust, but would involve putting your launch of floatbox on a timer to give the page time to initialize its javascript.
var listener = addEvent( window, 'load', function() { setTimeout(showAlertsystem_alerts, 300); }, false );
Member
Registered: Apr 2009
Posts: 52
Location: Everett, WA
admin wrote
The second approach is probably not as robust, but would involve putting your launch of floatbox on a timer to give the page time to initialize its javascript.
var listener = addEvent( window, 'load', function() { setTimeout(showAlertsystem_alerts, 300); }, false );


Thank you admin for your response... I ended up putting a pause in the loading of the FB with the setTimeout option like you suggested... I'd wanted to avoid that but it seems to have worked and I can live with it.

I posted another issue I was having here:
http://floatboxjs.com/forum/topic.php?post=1555#post1555

I'm not sure if it's related but it's another issue I've run into after upgrading and would love some help on.

Thank you for your time and especially for creating such a kick-ass product.
Administrator
Registered: Aug 2008
Posts: 3382
I can't manage to build a page where code fired by window.onload finds fb uninitialized at the time that code is fired. If there's a way you can post an online page that has this behaviour, I'd love to see it.

Page: 1