Re-open floatboxes on reload/refresh?

Page: 1

Author Post
nisse
Guest
Thanks for THE best lightbox out there!

I have a site where the customers use floatbox very much, but they keep complaining about having to re-open the lightbox and navigate to where they where if they reload/refresh the page.

Is there any way around this? Cookie perhaps?
Like fetching current iframe URL and adding it to a cookie, then re-open it on reload?

Thanx
« Last edit by Unknown on Fri Apr 03, 2009 11:28 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
There's not much that's already built in to floatbox that would help with this. But my first, and I think the obvious question is: If your customers don't want to exit from their current page and start over, why are they refreshing/reloading their browsers? The whole premise of this baffles me.

I suppose if you really do need cover for folks who hit the reload button and then regret it, cookies are probably the way to go. This would be up to you to code. You could hack the floatbox code to write a cookie to capture the last page displayed. This cookie writing would likely be inserted near or at the end of the showContent function. You would need to pair that with a page onload function that looks for that cookie and launches the last item using fb.loadAnchor.

Or, you could suggest to those folks who complain because they don't want their page to reload that maybe they could refrain from hitting the reload button.
nisse
Guest
Thank you for the swift reply.

The problem is that i have a blog nested inside a floatbox and have a blog on one of the pages, and people refresh/reload to see new comments. Of course, this closes the floatbox. And then people don?t remember what blog-post they was on :(

I will try to learn how to set up cookies, i have never done that before and don?t know anything about javascript.

Would you be interrested in doing it fo a sum of money? It would still be cheaper than me spending days trying to figure it out.
Administrator
Registered: Aug 2008
Posts: 3382
Aahhh. I knew there must be something I was missing in the requirement.

I don't think you need something to handle folks doing a browser refresh. I think you need a little "refresh contents" link in the floatbox caption. Yes? No?

Such a link is not too hard. The caption can take html, that html can be an anchor, and that anchor can contain an onclick action to reload the current content in the same (existing) box. Here's how to do it.

We're looking to build an anchor that runs the following code:
parent.fb.loadAnchor(parent.fb.currentItem.href, parent.fb.currentItem.rev + ' sameBox:true');

That code should be fairly obvious what it's doing. We just need to wrap it in an anchor so it can fire when clicked.
<a href="#" onclick="parent.fb.loadAnchor(parent.fb.currentItem.href, parent.fb.currentItem.rev + ' sameBox:true'); return false;">refresh contents</a>

But a caption can not directly accept this html code. It (usually) messes up the browser's parsing of the page. So we have to escape the html entities in that caption string. < becomes &lt; > becomes &gt; and " becomes &quot; It starts to look a little ugly but is still conceptually simple.
&lt;a href=&quot;#&quot; onclick=&quot;parent.fb.loadAnchor(parent.fb.currentItem.href, parent.fb.currentItem.rev + ' sameBox:true'); return false;&quot;&gt;refresh contents&lt;/a&gt;

The cut-and-pasteable caption option built from this looks like:
caption:`&lt;a href=&quot;#&quot; onclick=&quot;parent.fb.loadAnchor(parent.fb.currentItem.href, parent.fb.currentItem.rev + &#039; sameBox:true&#039;); return false;&quot;&gt;refresh contents&lt;/a&gt;`

(Note that the backquotes are required for correct parsing.)

And finally, an anchor with that caption pasted into its rev attribute might look like this:
<a href="myBlog.php" rev="caption:`&lt;a href=&quot;#&quot; onclick=&quot;parent.fb.loadAnchor(parent.fb.currentItem.href, parent.fb.currentItem.rev + ' sameBox:true'); return false;&quot;&gt;refresh contents&lt;/a&gt;`">my blog</a>
nisse
Guest
Thank you, this worked perfectly!

Is this possible:

I have this login button that says login, it opens a iframe floatbox.
When the user have logged in, i want the parent of that floatbox to reload
when the user closes the box, by clicking outside of the floatbox.

If it is, how can i do that?
« Last edit by Unknown on Sat Apr 11, 2009 3:33 pm. »

Page: 1