Results 1 to 5 of 5

Thread: Help to Remember last tab used in the Tab Content Script (v 2.2)

  1. #1
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help to Remember last tab used in the Tab Content Script (v 2.2)

    I am using the Tab Content Script (v 2.2). After closing all browser windows and then coming back to my site at a later time, I want the script to be able to remember the last tab I was on.

    I am wondering if anyone could help me with this. Is this possible?

    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, the ajaxtabs.js script only supports session only persistence. So it will need to be edited. Open it up with a text only editor like NotePad. At the beginning add the highlighted:

    Code:
    //** Ajax Tabs Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    //** Updated Oct 21st, 07 to version 2.0. Contains numerous improvements
    //** Updated Feb 18th, 08 to version 2.1: Adds a public "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically. Only .js file changed from v2.0.
    //** Updated April 8th, 08 to version 2.2:
    //   -Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0) 
    //   -Modified Ajax routine so testing the script out locally in IE7 now works 
    
    var ddajaxtabssettings={}
    ddajaxtabssettings.bustcachevar=1  //bust potential caching of external pages after initial request? (1=yes, 0=no)
    ddajaxtabssettings.loadstatustext="<img src='ajaxtabs/loading.gif' /> Requesting content..." 
    ddajaxtabssettings.persitdays=1  //Set number of days for persistence, use 0 for session only
    Next find this function:

    Code:
    ddajaxtabs.setCookie=function(name, value){
    	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
    }
    Change it to:

    Code:
    ddajaxtabs.setCookie=function(n, v, d){
        d = d || ddajaxtabssettings.persitdays || null;
        if(d){var dt = new Date(); 
          dt.setDate(dt.getDate() + d);
          d = '; expires=' + dt.toGMTString();}
      document.cookie = n + '=' + escape(v) + (d || '') + '; path=/';
      }
    Save and use this modified version. If desired, you may change the ddajaxtabssettings.persitdays value at the beginning of the file. Whatever it is set to will be the number of days the cookie will persist for.

    Also be sure to enable persistence in your on page ddajaxtabs declaration, ex:

    Code:
    var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    However, if the browser (yours or anyone else's) is set to not accept cookies or to destroy cookies on exit, this will not work. Generally though most folks accept cookies and allow them to persist from session to session if set that way by this script.
    Last edited by jscheuer1; 12-13-2009 at 12:16 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Finally getting back

    OK I'll try it.

    Thanks for your help John.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I just double checked and there may be a problem in some browsers, you should change (in the new setCookie function):

    Code:
    ddajaxtabs.setCookie=function(n, v, d){
        d = d || ddajaxtabssettings.persitdays || null;
        if(d){var dt = new Date(); 
          dt.setDate(dt.getDate() + d);
          d = '; expires=' + dt.toGMTString();}
      document.cookie = n + '=' + escape(v) + (d || '') + '; path=/';
      }
    to:

    Code:
    ddajaxtabs.setCookie=function(n, v, d){
        d = d || ddajaxtabssettings.persitdays || null;
        if(d){var dt = new Date(); 
          dt.setDate(dt.getDate() + d);
          d = '; expires=' + dt.toGMTString();}
      document.cookie = n + '=' + v + (d || '') + '; path=/';
      }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your reply and checking

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •