Results 1 to 2 of 2

Thread: Persistent State problem

  1. #1
    Join Date
    Jul 2008
    Location
    boston, ma
    Posts
    88
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Persistent State problem

    Hi,
    A weird thing is occuring and I have no idea why. I was working on a left side navigation in a copy of a html page. I made the nav so part of it will stay open depending on the page. It works great in say examiner copy.html. When I change the file name to just examiner.html, the js code for the state doesn't work. I tried this on a couple of pages and the code only works if the file name has a space and word after it.
    Why would this being doing that??? How do I fix this?
    example of it working

    example of it not working

    here is the bit of css for the persistent state
    Code:
    <li><a class="qm-startopen qmparent" href="javascript:void(0)">Group Two</a>
    here is the bit of js code
    HTML Code:
    //Add-On Code: Show Subs Onload
    if(!qmad.sopen){qmad.sopen=new Object();qmad.sopen.log=new Array();if(window.attachEvent)window.attachEvent("onload",qm_sopen_init);else  if(window.addEventListener)window.addEventListener("load",qm_sopen_init,1);};function qm_sopen_init(e,go){if(window.qmv)return;if(!go){setTimeout("qm_sopen_init(null,1)",10);return;}var auto_close=false;var i;var ql=qmad.sopen.log;for(i=0;i<10;i++){var a;if(a=document.getElementById("qm"+i)){var ss=qmad[a.id];if(ss&&!ss.showload_active)continue;if(ss&&ss.showload_auto_close)auto_close=true;var dd=a.getElementsByTagName("DIV");for(var j=0;j<dd.length;j++){if(dd[j].idiv&&dd[j].idiv.className.indexOf("qm-startopen")+1){ql.push(dd[j].idiv);var f=dd[j][qp];if(!qm_a(f)){var b=false;for(var k=0;k<ql.length;k++){if(ql[k]==f.idiv)ql[k]=null;}ql.push(f.idiv);f=f[qp];}}}}}var se=0;var sc=0;if(qmad.tree){se=qmad.tree.etype;sc=qmad.tree.ctype;qmad.tree.etype=0;qmad.tree.ctype=0;}for(i=ql.length-1;i>=0;i--){if(ql[i]){qm_oo(new Object(),ql[i],1);if(!auto_close)qm_li=null;}}if(qmad.tree){qmad.tree.etype=se;qmad.tree.ctype=sc;}}
    
    //Add-On Code: Persistent States With Auto Open Subs Option
    if(!qmad.sopen_auto){qmad.sopen_auto=new Object();qmad.sopen_auto.log=new Array();if(window.attachEvent)window.attachEvent("onload",qm_sopen_auto_init);else  if(window.addEventListener)window.addEventListener("load",qm_sopen_auto_init,1);};function qm_sopen_auto_init(e,go){if(window.qmv)return;if(!go){setTimeout("qm_sopen_auto_init(null,1)",10);return;}var i;var ql=qmad.sopen_auto.log;for(i=0;i<10;i++){var ss=qmad["qm"+i];if(!ss||!ss.sopen_auto_enabled)continue;var curl=unescape(window.location.href).toLowerCase();curl=qm_sopen_auto_clean(curl);var a;if(a=document.getElementById("qm"+i)){var dd=a.getElementsByTagName("A");for(var j=0;j<dd.length;j++){var aurl=unescape(dd[j].getAttribute("href",1)).toLowerCase();aurl=qm_sopen_auto_clean(aurl);loc=curl.length-aurl.length;if(aurl&&aurl!="#"&&loc>-1&&curl.indexOf(aurl)+1){var wa=dd[j];if(wa.cdiv)wa=wa.cdiv;while(!qm_a(wa)){if(wa.tagName=="DIV"){if(wa.idiv){if(ss.sopen_auto_show_subs)ql.push(wa.idiv);x2("qmpersistent",wa.idiv,1);}}else  if(wa.tagName=="A")x2("qmpersistent",wa,1);wa=wa[qp];}}}}}var se=0;var sc=0;if(qmad.tree){se=qmad.tree.etype;sc=qmad.tree.ctype;qmad.tree.etype=0;qmad.tree.ctype=0;}for(i=ql.length-1;i>=0;i--){if(ql[i]){qm_oo(new Object(),ql[i],1);qm_li=null;}}if(qmad.tree){qmad.tree.etype=se;qmad.tree.ctype=sc;}};function qm_sopen_auto_clean(url){url=url.replace(/\:/g,"");url=url.replace("localhost","");url=url.replace("file","");url=url.replace(/\\/g,"");url=url.replace(/\//g,"");url=url.replace(/\./g,"");return url;}

  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

    Quote Originally Posted by Irishcash33 View Post

    here is the bit of css for the persistent state
    Code:
    <li><a class="qm-startopen qmparent" href="javascript:void(0)">Group Two</a>
    That's not css, it's HTML, how is it relevant to the problem? That href would do nothing, except that in some browsers, when clicked it will signal to the browser that it is time to begin unloading the page, which I'm sure is not your intention.

    Your javascript code is difficult to read, and probably way more complex than it needs to be.

    Write it out using one line for each statement. That will make it clearer to you and anyone reading it what it does. Also, include comments in the code to show what you think it is doing. That will help us to help you, and just thinking about it may resolve the issue for you.

    I did notice that the link for examiner is the same on both pages. If your code keys off of the href, it should be different on the different pages.

    Generally one uses cookies for persistence.
    - John
    ________________________

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

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
  •