Click here to Skip to main content
Click here to Skip to main content

FTab (Floating Tabs)

By , 29 Sep 2009
 

Introduction

FTab (Floating Tabs) is a COOL cross browser DHTML floating window script with support for tabs. The floating window can move/resize/minimize/maximize/fixed/show modal, and the states(size/positions/minimized/maximized or others) can save to cookie. It's so easy to configure that you only need put your content into separate tabs and then call:

FTab('ftab1',left, top, width, height, style)

A COOL floating window with tabs will be shown! You can also create a window without floating. Open the example page to see how COOL FTab is!
Supports a wide variety of browsers such as Internet Explorer, Opera, Firefox, Google Chrome and Safari.

Using the Code

A simple code is shown here. For full features, see the demo page.

  1. Add this in the head:
    <link rel="stylesheet" href="ftab.css">
    <script type="text/javascript" src="ftab.js"></script>
  2. Add contents in the body:
    <!-- FTabMain START --> 
    <div id="ftab1" title="ftab1's title" style="display:none;"> 
    
    <!-- FTabPage START --> 
    <div title="Page1"> 
    page1<br> 
    </div> 
    <!-- FTabPage END --> 
    <!-- FTabPage START --> 
    <div title="Page1"> 
    page1<br> 
    </div> 
    <!-- FTabPage END --> 
    
    </div> 
    <!-- FTabMain END --> 
  3. After contents, add JavaScript to initialize FTab:
    <script type="text/javascript"> 
    FTab('ftab1',330,90,160,50,''); 
    </script>

Points of Interest

  1. Params for initializing FTab:
    function FTab(tabID, left, top, width, height, style, showPageIndex)

    can be used like: (notice no 'new' as var o = new FTab(...), but no errors even if you use 'new'.)

    var o = FTab(tabID,10,10,200,160, 
      'title:1;minmax:1;close:1;move:1;status:1;resize:1;scroll:1;tab:1;',0);
      o.show(pageIndex);

    As options, here are all (1 for default true):

    title:1;minmax:1;close:1;move:1;status:1;resize:1;scroll:1;tab:1;
      tabrect:1;expandable:0;cookie:1;modal:0;center:0;

    It can also be like this:

    FTab(tabID,10,10,200,160,'').show(pageIndex);

    When creating FTab, you need these params (left, top, and others), but next time, you only need tabID to refer to FTab.
    For styles, default of all params is 1. If no title(title:0), then no close and minmax buttons even set them as 1, and also no moving. If there is no status (status:0), then there is no resize.
    If set 'expandable:1;' (default is 0), then auto set this style:

    noTitle = false;
    noResize = true;
    noMinMax = true;
    noClose = true;
    noMove = true;
    noStatus = true;
    noFixed = true;
    modal = false;
    center = false;
  2. After initializing, you can use these functions:
    function show(pageIndex);
    function switchMinMax();
    function switchFixed();
    function hide();
    function setTitle(str);
    function setTabTitle(pageIndex, str);
    function setBody(pageIndex, str);
    function setURL(pageIndex, url);
    function setStatus(str);
    function getSelectedIndex();
    function isHide();
    function isMin();
    function isFixed();
    function move(left, top, width, height);
  3. Support for user's event:
    Here you can do something if you like.
    FTabs.OnPageShow = function(ftab,index) 
    { 
      window.status='FTab_OnPageShow,window:'+ftab.id + ', 
    	index:' + index + ' is shown.'; 
    } 
    FTabs.OnActing = function(ftab) 
    { 
      window.status='FTab_OnActing,window:'+ftab.id + '.'; 
    } 
    FTabs.OnDeActing = function(ftab) 
    { 
      window.status='FTab_OnDeActing,window:'+ftab.id + '.'; 
    } 
    FTabs.OnMinMax = function(ftab, isMin) 
    { 
      window.status='FTab_OnMinMax,window:'+ftab.id + ', isMin:' + isMin; 
    } 
    FTabs.OnHide = function(ftab) 
    { 
      window.status='FTab_OnHide,window:'+ftab.id + '.'; 
    } 

Extend Style

  • Customized for user
  • Can set other colors or styles

Click "ExtStyle" buttons in the example page.

History

  • First released on 2008/07/08
  • Updated on 2008/8/22 - Added expandable style
  • Updated on 2009/6/07 - JS source is compressed added to only 11 KB!
  • Updated on 2009/6/21 - Added fixed and modal dialog features.

For details, visit last version & demo.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

uuware
Software Developer
China China
Member
From china, and location at japan.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralGreat work!!!memberliquizing17 Nov '12 - 3:25 
Great work, very thanks
GeneralRe: Great work!!!memberuuware15 May '13 - 20:08 
thanks Smile | :)
BugProblems about cookiesmemberMember 93297781 Aug '12 - 23:26 
Hi,
It’s a great work. But there are two problems about cookies.
If I set the URL of a tab through function doSetURL cookies don’t remember it and, after refresh, the tab charges with the old URL.
The same thing occurs on creating a tab or a window dynamically: after refresh it isn’t visible.
Could you fix it please? Thanks in advance.
GeneralRe: Problems about cookiesmemberuuware5 Aug '12 - 4:21 
Thank you for come to here.
 
1,The FTab don't remember URL for it is not a state but I think it is data.
You can do it, read from/save to cookies before call doSetURL.
 
2,I think FTab can save its states.
But it need you create it like next at each page load.
<script type="text/javascript">
FTab('ftab1',580,300,400,260,'');
FTab('ftab4',600,220,150,60,'tabBlush | :O ;minmaxBlush | :O ;closeBlush | :O ;scrollBlush | :O ;');
</script>
 
the sample is http://www.uuware.com/js_ftab_en.htm[^].
GeneralRe: Problems about cookiesmemberMember 93297785 Aug '12 - 22:24 
Thank you very much for your fast reply.
 
1) I have changed the code of ftab_src.js in this manner:
...
function
FTab_SaveConfig(name,url,left,top,width,height,nState,nZIndex)

if(typeof(url)=='number') sitems[0] = ''+url;

but with no success: when contents of iframe changes, cookies don’t remember it.
 
2) It would be very nice to have a possibility to create and destroy windows dynamically, on the fly, as here:
http://www.dhtmlgoodies.com/scripts/floating_window/floating_window.html
 
Can Ftab do it and remember the state of created windows for use in future sessions?
GeneralMy vote of 5memberonurag1920 May '12 - 2:41 
My vote
GeneralMy vote of 5memberMd. Touhidul Alam Shuvo21 Jun '11 - 23:35 
Thanks, that was really need for Web developer
GeneralDemomemberJohnny J.30 Sep '09 - 20:32 
I Checked out the demo. What does the pushpin button do? It doesn't seem like anything happens when you toggle that?
 
Otherwise: Good work.
 
Cheers,
Johnny J.
GeneralRe: Demomemberuuware1 Oct '09 - 14:56 
Thanks for your "Good work".
 
Really?I am sorry for that.
Can you tell me your browser and the version about it.
May be I can try about it.
GeneralRe: DemomemberJohnny J.1 Oct '09 - 19:04 
you're welcome.
 
If the pushpin is to make the window immovable, then it doesn't work in my IE (version 7.0.6001.18000) - If it's something else then I might just not understand what it is... Wink | ;-)
 
Cheers,
Johnny
GeneralRe: Demomemberuuware1 Oct '09 - 19:25 
Thanks for your replay.
 
My IE is 7.0.5730.11, but work fine.
Oh, I understood, pushpin is to make the window immovable, but not for you Laugh | :laugh: .
It is means when browser's scrollbar is shown, even move scrollbar up or down, the position of window is fixed.
But even pushpin is pushed, YOU, can move it every where if you want.
GeneralRe: Demomemberac-chan9 Oct '09 - 11:48 
I need to modify the script to work with may framework and add some features. But the code ist packed. Can i get a unpacked version?
GeneralRe: Demomemberuuware12 Oct '09 - 14:47 
Yes, off cause.
All the full source is in the zip file with the name *_src.js.
 
Thanks for your use.
GeneralVery Nice WorkmvpAbhijit Jana29 Sep '09 - 10:53 
Great one ! 5 from me Big Grin | :-D Thumbs Up | :thumbsup:
 
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Visit My Latest Article : Beginner's Guide : Exploring IIS 6.0 With ASP.NET

JokeRe: Very Nice Work [modified]memberuuware29 Sep '09 - 14:40 
thanks you.
 
modified on Wednesday, September 30, 2009 9:30 AM

GeneralOf browser compatibility ...memberMember 33441294 Jul '09 - 3:45 
Thank you for the exceptionally great js-library!
 
I notices that the script-library worked well in IE, Firefox and Safari,
but, in Opera (in the latest version) the resizing did not work.
 
I would like to ask if it is too much to be asked if you could
work on the library yet a bit more to bring its compability to
Opera too (and maybe Chrome that I have not tested)?
 
Thank you very much,
 
Matti
GeneralRe: Of browser compatibility ...memberuuware5 Jul '09 - 15:20 
It's so reasonable that I cannot refuse you even I no plan for put it work with Opera.
I modified it,only one word,now it work with Opera.
Also I tested it with Chrome,every thing seems fine.
Now I should say:
It has been tested on IE5.5, IE6, IE7, Firefox2, and Firefox3, Opera 9.6, Chrome 2.0, Safari 4.0.
(should download from link of:Last version & demo page)
GeneralRe: Of browser compatibility ...memberMember 33441296 Jul '09 - 0:10 
Thank you for your reply!
 
I tried again the code (Ver 1.0 Download All FTab files - 17 Kb; http://www.uuware.com/js_ftab_en.htm) in Opera 9.64. - But for some reason the moving and the manual resizing of the floating tab window did not still work.
 
I wonder if I downloaded the correct version? - If that is so, could you please explicitly set the direct downloading link to the .zip file of modified file version.
 
Or if it is still question of (moving and manual resizing) not working in Opera (9.64), may I ask you still to pay your attention to the problem. This is so fine gadget that it is absolutely worthy of making it work on all major browsers!
 
Thank you,
 
Matti Thumbs Up | :thumbsup:
 
ps. in your demo page at href="http://www.uuware.com/ftab.html the moving and the manual resizing of the floating tab windows did not work either in my Opera 9.64 browser !!!
GeneralRe: Of browser compatibility ...memberuuware6 Jul '09 - 0:37 
I think you need refresh your Opera.
I test again in demo page and also js_ftab_en.htm,i can move it.
(Now I am redirect my site from google's app to webhostingpad,perhaps you need wait for a while,I will update codeproject soon.)
At line 679 of ftab_src.js, should be:
if(window.getSelection) window.getSelection().removeAllRanges();
else if(document.selection && document.selection.empty) document.selection.empty();
Thank you.
GeneralRe: Of browser compatibility ...memberMember 33441296 Jul '09 - 13:30 
Hi Again,
 
and thank you for further information ...
 
At line 679 of ftab_src.js, should be:
if(window.getSelection) window.getSelection().removeAllRanges();
else if(document.selection && document.selection.empty) document.selection.empty();
 
... which solved the problem! - and now I was capable of resizing the tab-windows also in Opera.
 
But to make the demo page really work, I had to also change the javascript-file from
"ftab.js" to "ftab_src.js" - i.e.:
 
from
<script type="text/javascript" src="ftab.js"></script>
to
<script type="text/javascript" src="ftab_src.js"></script>
 
What is the difference between these too files?
 
Regards,
 
Matti
GeneralRe: Of browser compatibility ...memberuuware6 Jul '09 - 14:46 
Thank you.
ftab_src.js is source file, and ftab.js is same file but with packed to reduce its size for high speed transport.
you can use any one of the too files.
GeneralBrowser Back Buttonmembercwlocke25 Jun '09 - 10:08 
I noticed that when I go to the latest version/demo page the back button on my browser doesn't work as expected (IE 8). There are several extra pages between this page (code project) and the one I finally end up at. Is this a side effect of FTab or just the way the other site works?
GeneralRe: Browser Back Buttonmemberuuware30 Jun '09 - 18:01 
I had not test with IE8, but I'm sure there does nothing to back button or history of Browser in FTab.
GeneralVery nicememberJimmiepotter24 Jun '09 - 8:30 
Thanks a lot
JokeRe: Very nicememberuuware24 Jun '09 - 11:46 
Thanks for coming.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 29 Sep 2009
Article Copyright 2009 by uuware
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid