Loading a floatbox from javasctipt

Page: 1

Author Post
davejm
Guest
Apologies if this seems like a silly question, but how do I launch a floatbox automatically via javascript without the user having to click on a link?

I've tried this code, without any joy:-

<script type="text/javascript">
fb.loadAnchor(&#039;prompt.php&#039;, &#039;width:300 height:300 autoStart:true&#039;);
</SCRIPT>


Am I missing something claringly obvious? (I don't know much javascript)

Cheers,

Dave

ps, This is an excellent tool, great work.
Administrator
Registered: Aug 2008
Posts: 3382
I think you are trying to autoStart an item when the page loads. If this is so, just set up a regular floatbox anchor and add autoStart:true to the rev tag options. All this is detailed in the docs and the options reference.

You can't use inline javascript to fire fb.loadAnchor because at the point in the page flow, floatbox has not yet initialized - the fb variable and object doesn't yet exist. Use fb.loadAnchor to launch a floatbox in response to some user event like a click, but use autoStart on an anchor to, well..., autoStart something.
davejm
Guest
Cheers mate... it didn't twig that I could use the autostart in an anchor tag, as I always assumed they were only 'clickable'.

Thanks! :)
Member
Registered: Jan 2009
Posts: 24
Actually, if you know that you will automatically load the floatbox on each page, then you can just call the fb.loadanchor in the floatbox.js (at the end).

Now you would be wondering that what would it do good to load floatbox on each page? Well imagine that you have a "feedback" button on each page and when use clicks on it, you want the floatbox to load, but you don't want to just load floatbox.js on every page because that would be a waste of bandwith and it would slow things down. So you would do a javascript append, and then set the src to that modified floatbox file, so then you won't have to call fb.loadanchor.

Actually calling fb.loadanchor right after calling a normal floatbox file in the method described above does not work for some reason, so I prefer to call it just thru a modified floatbox.js.

Page: 1