Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 4 123 ... LastLast
Results 1 to 15 of 60
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Can someone suggest the proper method for passing variables across pages

    Hi,

    I just changed my underlying navigation system to use server-side includes, and now a bunch of my scripts that are onclick, event-based functions are now not working properly because the page is being reloaded every time.

    The types of events I need to pass from page to page are not too complex... for ex:

    Code:
    <div id="navcontainer" onclick="zxcResetImages('links_BW'); zxcOnceClick('nav_helper')">
    		<ul id="navlist">
    			<li><a href="infoInclude.php" id="about" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">About Us</a></li>
    			<li><a href="YPPInclude.php" id="people" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">People:<br>Past and Present</a></li>
    			<li><a href="socialInclude.php" id="media" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">Media / Press</a></li>
    			<li><a href="medicalInclude.php" id="getinvolded" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">Get Involved</a></li>
    			<li><a id="donate" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">Donate</a></li>
    			<li><a id="forums" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">Forums</a></li>
    			<li><a id="extraLinks" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);">Links</a></li>
    		</ul>
    	</div>
    	<div id="emailSection"></div>
    Code:
    <!--
    
    LastID = ""
    function mOver(obj){
    if(LastID != obj.id){
    	if (obj.id == "people") { document.getElementById(obj.id).className="mOverTwoLine" }
    	else {document.getElementById(obj.id).className="mOver" }
    }
    }
    
    function mOut(obj){
    if(LastID != obj.id){
    document.getElementById(obj.id).className="default"
    }
    }
    
    function mClick(obj){
    if (obj.id == "people") { document.getElementById(obj.id).className="mDownTwoLine" }
    	else {document.getElementById(obj.id).className="mDown" }
    if (LastID != obj.id && LastID != ""){
    document.getElementById(LastID).className="default"
    }
    
    LastID = obj.id
    
    }
    
    function mClear(){
    
    if(LastID!=""){
    document.getElementById(LastID).className="default"
    LastID=""
    }
    
    }
    
    
    
    // -->
    How do people usually get around issues like this?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    a visual example of this is:
    if you go to www.enviromark.ca/head/index.htm and click on a link on the right nav, it turns blue.

    if you go to www.enviromark.ca/head/indexInclude.php and do the same... because the page reloads it doesnt stay blue

    ---------
    edit:
    I basically think that now, since i'm using server-side includes, that the script will need to assign the classes onload as opposed to changing the inline class state... is this an accurate assumption... or how is this usually worked-around?
    Last edited by canadianjameson; 08-22-2007 at 10:58 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Server Side Includes have no effect on JavaScript whatsoever as all the javaScript sees is the page with the included code inserted. Your must have therefore changed something else that is causing the problem.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Right but as far as I see it the problem is that the page is being reloaded onclick right (or have i missed something?). This script changes the class of an object, but since the change is being made to the html it is nullified when then new link opens.

    am i wrong about how this works?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <link rel="stylesheet" href="http://www.enviromark.ca/head/css/rightNav.css" type="text/css">
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    var LastID = ""
    
    function mOver(obj){
     if(LastID != obj.id){
      if (obj.id == "people") { document.getElementById(obj.id).className="mOverTwoLine" }
      else {document.getElementById(obj.id).className="mOver" }
     }
    }
    
    function mOut(obj){
     if(LastID != obj.id){
      document.getElementById(obj.id).className="default"
     }
    }
    
    function mClick(obj){
     if (obj.id == "people") { document.getElementById(obj.id).className="mDownTwoLine" }
     else {document.getElementById(obj.id).className="mDown" }
     if (LastID != obj.id && LastID != ""){
      document.getElementById(LastID).className="default"
     }
     LastID = obj.id
     zxcSetCookie(obj,'default');
    }
    
    function mClear(){
     if(LastID!=""){
      document.getElementById(LastID).className="default"
      LastID=""
     }
    }
    
    
    
    /*]]>*/
    </script>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    // Remove/Replace Rows zxcPart2  (30-Jan-2005)
    // by Vic Phillips http://www.vicsjavascripts.org.uk/
    
    // Functional Code - NO NEED to Change
    var zxcCookie='fred';
    
    var zxcDays=1;
    
    var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
    function zxcUseCookie(){
     var zxcargs=zxcUseCookie.arguments;
     for (var zxc0=2;zxc0<zxcargs.length;zxc0++){
      document.getElementById(zxcargs[zxc0]).usecookie=true;
     }
     zxcCookie=zxcargs[0];
     zxcGetCookieValue();
    }
    
    function zxcSetCookie(zxcobj,zxccls){
     var zxcp=zxcobj.parentNode.parentNode.parentNode;
     var zxcas=zxcp.getElementsByTagName('A');
     for (var zxc0=0;zxc0<zxcas.length;zxc0++){
      if (zxcas[zxc0].className!=zxccls) break;
     }
     document.cookie=zxcCookie+'='+escape(zxc0+':'+zxcas[zxc0].className)+';expires='+zxcExp+';path=/;';
    }
    
    function zxcGetCookieValue(zxcid){
     var zxcval=zxcGetCookie(zxcCookie);
     if(!zxcval){ return; }
     var zxcas=document.getElementById(zxcid).getElementsByTagName('A');
     zxcas[zxcval.split(':')[0]].className=zxcval.split(':')[1];
     LastID=zxcas[zxcval.split(':')[0]].id;
    }
    
    function zxcGetCookie(zxcnme) {
     var zxcst=document.cookie.indexOf(zxcnme+"=");
     var zxclen=zxcst+zxcnme.length+1;
     if ((!zxcst)&&(zxcnme != document.cookie.substring(0,zxcnme.length))) return null;
     if (zxcst==-1) return null;
     var zxcend=document.cookie.indexOf(";",zxclen);
     if (zxcend==-1) zxcend=document.cookie.length;
     return unescape(document.cookie.substring(zxclen,zxcend));
    }
    
    //-->
    </script>
    </head>
    
    <body onload="zxcGetCookieValue('navcontainer');">zxcResetImages('links_BW'); zxcOnceClick('nav_helper')
    <div id="navcontainer" onclick="">
    		<ul id="navlist">
    			<li><a href="infoInclude.php" id="about" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false">About Us</a></li>
    			<li><a href="YPPInclude.php" id="people" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">People:<br>Past and Present</a></li>
    			<li><a href="socialInclude.php" id="media" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Media / Press</a></li>
    			<li><a href="medicalInclude.php" id="getinvolded" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Get Involved</a></li>
    
    			<li><a id="donate" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Donate</a></li>
    			<li><a id="forums" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Forums</a></li>
    			<li><a id="extraLinks" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Links</a></li>
    		</ul>
    	</div>
    
    </body>
    
    </html>
    PS remove the return false on the link onclick
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • Users who have thanked vwphillips for this post:

    canadianjameson (08-23-2007)

  • #6
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Vic this is perfect!

    I was wondering if you could explain to me how exactly this works (as it seems that there are no variables to alter in the actual code -- which i saved as setCookie.js

    I ask because in the future I will need to throw this into other functions and I don't want to have to bug you every time

    for example, on the current page I need to apply this to the onload event for setTimeout(assignMouseOver,5000); as well as for zxcInitImages('logoC','links_BW')... but i dont know where in the actual body of the js to put it... or even if the setCookie script can be used for more than one function, or if I need a second instance of the script just to use it a second time. I ask because I noticed that it set the cookie called 'fred', which if called twice might conflict (?)

    lol, atleast i'm trying to learn

    this is the assignMouseOver() function
    Code:
    /*<![CDATA[*/
    function assignMouseOver(){
     var olinks_BW = document.getElementById("links_BW");
     var oldOnMouseOver = olinks_BW.onmouseover;
     if (typeof oldOnMouseOver != 'function') {//If onmouseover is not a function we can safely overwrite it.
      olinks_BW.onmouseover = function(){zxcOnce('nav_helper');}
     } 
     else {//Otherwise create a new function that calls the old onmouseover function plus our new function.
      olinks_BW.onmouseover = function() {
       if (oldOnMouseOver) {
        oldOnMouseOver();
       }
       zxcOnce('nav_helper');
      }
     }
    }
    
    
    function zxcOnce(zxcid){ 
     	if (!document.getElementById(zxcid)['opacityoop']) zxcAnimator('opacity',zxcid,100,0,'linear',1000)
    }
    
    function zxcOnceClick(zxcid){
    	 if (!document.getElementById(zxcid)['opacityoop']) zxcAnimator('opacity',zxcid,100,0,'linear',1000);
    }
    
    /*]]>*/
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #7
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Cant think too clear at the moment but

    There may be as many function calls as required from a <BODY> or window onload event

    easiest is to have a function that includes all the required calls and call that function from the onload event.

    the site cookies can contain up to 4k of data on the users machine.
    This can be in one cookie name or in multiple cookies each with a unique name.

    The only global variables in the posted example are two customising varibles for the cookie name and the number of day to expiry and one with the expiry time in milli seconds.

    Hopes this answers your some of your questions.

    BTW ment to ask before why you are not using an IFRAME instead of reloading new pages our using ajax for the dynamic content.

    You will need to explain again what you want doing with the assignMouseOver() function.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #8
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    I spoke a wee bit too soon

    We need to make two modifications to the script -- one minor and one... i dunno i guess not too hard

    1) the function mClear() no longer works. This is called when any of the links in 'Links_BW are clicked and it resets the classes to 'default'

    2) if a person leaves the page, and comes back a bit later the same day, the class from the link they were last on is still in the cookie and shows that button as being active.

    What i think we need to do now, because people can bookmark / link directly to whatever section of the page they want (instead of being forced to go to index.htm), is have a way for onload the script to verify what page it is and set that that button as 'active' (unless they are on the index page at which point no button is 'active' -- this applies to both the right navigator and to the links_BW script.

    Can this be done?

    Sorry for all the hassles Vic... every page I make from now on will use server-side includes so we wont have to go through this again

    edit: we cross posted so i will now answer your questions in the next post
    Last edited by canadianjameson; 08-23-2007 at 10:38 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #9
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hey Vic,

    I'm using the server-side includes because the ajax script I had before wasn't DOM compliant and was throwing all kinds of errors with the slide-show I was / am using. I chose includes over iframes mainly because iframes are depreciated and being phased out in the coming years, and I don't think this organization will have a budget to recode the page in a few years because i chose iframes over includes now. The explanation i was given for why the ajax script should be removed was this:

    (by toggler he meant the ajax script)
    HI Jay,

    The entire issue is that the paradigm is flawed, since the toggler simply
    copies the html markup, and does not address any dom-related objects that
    may have been instantiated by the scripts on the page that was loaded in,
    the toggler must never re-copy. Unlike a frames-based page, or even an
    iframe, the new page is not under it's own DOM, it is acting on and getting
    data from the same original parent page all of the time. This means hat the
    DOM and related objects can, and will, become corrupt. Since the toggler
    simply copies the raw markup into the div, none of the DOM-related objects
    are removed when toggling takes place, so in essence, when the toggler
    copies the markup a second time the now new SSM system is attempting to deal
    with an already DOM initialized slide show whose parameters are still that
    of the previous slide show. Jay, this technique is an exercise in futility,
    it will never work correctly... the toggler can never re-copy an SSM system,
    however, since the toggler is working with only one content div, when you
    toggle to other content the SSM markup has been removed from the page, but
    when re-copied it will not work correctly because the DOM objects from the
    previous SSM are still in the pages DOM, causing the new SSM to not work
    correctly because it cannot be re-initialized.

    Regards,
    Gerry Jacobsen
    http://www.projectseven.com

    As for the AssignMouseOver function

    It acts on the nav_heper.jpg file. What it does is, because users may not know that the black & white vertical icons are links, it tells the users to use those buttons... but once they know what to do, it doesnt need to be there anymore... so i use your fade script to fade it out when they onmouseover the links. the 5 second part is as a precaution to prevent them from accidentally onmouseovering before they get a chance to read it.

    I understand if you're tired, please take all the time you need to reply. I will be (edit: done) posting one other thread regarding a bug in the borderFade.js script, so also keep an eye out for that if you can. This only has to be functional by next Friday (when they want to release the site), so take your time
    Last edited by canadianjameson; 08-23-2007 at 10:37 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #10
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    1) the function mClear() no longer works. This is called when any of the links in 'Links_BW are clicked and it resets the classes to 'default'
    As far as I can see the clear still works(think I catered for it in function zxcGetCookieValue)

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <link rel="stylesheet" href="http://www.enviromark.ca/head/css/rightNav.css" type="text/css">
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    var LastID = ""
    
    function mOver(obj){
     if(LastID != obj.id){
      if (obj.id == "people") { document.getElementById(obj.id).className="mOverTwoLine" }
      else {document.getElementById(obj.id).className="mOver" }
     }
    }
    
    function mOut(obj){
     if(LastID != obj.id){
      document.getElementById(obj.id).className="default"
     }
    }
    
    function mClick(obj){
     if (obj.id == "people") { document.getElementById(obj.id).className="mDownTwoLine" }
     else {document.getElementById(obj.id).className="mDown" }
     if (LastID != obj.id && LastID != ""){
      document.getElementById(LastID).className="default"
     }
     LastID = obj.id
     zxcSetCookie(obj,'default');
    }
    
    function mClear(){
     if(LastID!=""){
      document.getElementById(LastID).className="default"
      LastID=""
     }
    }
    
    
    
    /*]]>*/
    </script>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    // Remove/Replace Rows zxcPart2  (30-Jan-2005)
    // by Vic Phillips http://www.vicsjavascripts.org.uk/
    
    // Functional Code - NO NEED to Change
    var zxcCookie='fred';
    
    var zxcDays=1;
    
    var zxcExp=new Date(new Date().getTime()+zxcDays*86400000).toGMTString();
    function zxcUseCookie(){
     var zxcargs=zxcUseCookie.arguments;
     for (var zxc0=2;zxc0<zxcargs.length;zxc0++){
      document.getElementById(zxcargs[zxc0]).usecookie=true;
     }
     zxcCookie=zxcargs[0];
     zxcGetCookieValue();
    }
    
    function zxcSetCookie(zxcobj,zxccls){
     var zxcp=zxcobj.parentNode.parentNode.parentNode;
     var zxcas=zxcp.getElementsByTagName('A');
     for (var zxc0=0;zxc0<zxcas.length;zxc0++){
      if (zxcas[zxc0].className!=zxccls) break;
     }
     document.cookie=zxcCookie+'='+escape(zxc0+':'+zxcas[zxc0].className)+';expires='+zxcExp+';path=/;';
    }
    
    function zxcGetCookieValue(zxcid){
     var zxcval=zxcGetCookie(zxcCookie);
     if(!zxcval){ return; }
     var zxcas=document.getElementById(zxcid).getElementsByTagName('A');
     zxcas[zxcval.split(':')[0]].className=zxcval.split(':')[1];
     LastID=zxcas[zxcval.split(':')[0]].id;
    }
    
    function zxcGetCookie(zxcnme) {
     var zxcst=document.cookie.indexOf(zxcnme+"=");
     var zxclen=zxcst+zxcnme.length+1;
     if ((!zxcst)&&(zxcnme != document.cookie.substring(0,zxcnme.length))) return null;
     if (zxcst==-1) return null;
     var zxcend=document.cookie.indexOf(";",zxclen);
     if (zxcend==-1) zxcend=document.cookie.length;
     return unescape(document.cookie.substring(zxclen,zxcend));
    }
    
    //-->
    </script>
    </head>
    
    <body onload="zxcGetCookieValue('navcontainer');">zxcResetImages('links_BW'); zxcOnceClick('nav_helper')
    <div id="navcontainer" onclick="">
    		<ul id="navlist">
    			<li><a href="infoInclude.php" id="about" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false">About Us</a></li>
    			<li><a href="YPPInclude.php" id="people" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">People:<br>Past and Present</a></li>
    			<li><a href="socialInclude.php" id="media" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Media / Press</a></li>
    			<li><a href="medicalInclude.php" id="getinvolded" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Get Involved</a></li>
    
    			<li><a id="donate" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Donate</a></li>
    			<li><a id="forums" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Forums</a></li>
    			<li><a id="extraLinks" class="default" onmouseover="mOver(this)" onmouseout="mOut(this)" onclick="mClick(this);return false;">Links</a></li>
    		</ul>
    	</div>
     <input type="button" name="" value="Clear" onclick="mClear();" />
    </body>
    
    </html>

    2) if a person leaves the page, and comes back a bit later the same day, the class from the link they were last on is still in the cookie and shows that button as being active.
    this can be catered for by secifying a few seconds for the Expiry time(.0001 of a day)


    Code:
    What i think we need to do now, because people can bookmark / link directly to whatever section of the page they want (instead of being forced to go to index.htm), is have a way for onload the script to verify what page it is and set that that button as 'active' (unless they are on the index page at which point no button is 'active' -- this applies to both the right navigator and to the links_BW script.
    Opps as each page has a different location there is no need for cookies, just interrogate the location and set the required conditions.

    You will need to identify what conditions need to be established for each page.


    Still cant stop thinking that if not an IFRAME a frameset would be easier.
    Last edited by vwphillips; 08-24-2007 at 12:40 AM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #11
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vwphillips View Post
    As far as I can see the clear still works(think I catered for it in function zxcGetCookieValue)
    odd, because when i go here (http://www.enviromark.ca/head/YPPInclude.php) for example, click one of the right buttons, then click a left nav button, the right one which has the blue background keeps it instead of going back to having class="default"

    (i havent checked the code you posted just below, so if you fixed it there then leave it and i'll test it tomorrow)

    this can be catered for by secifying a few seconds for the Expiry time(.0001 of a day)
    okay i see, I'll do that.

    Code:
    What i think we need to do now, because people can bookmark / link directly to whatever section of the page they want (instead of being forced to go to index.htm), is have a way for onload the script to verify what page it is and set that that button as 'active' (unless they are on the index page at which point no button is 'active' -- this applies to both the right navigator and to the links_BW script.
    Opps as each page has a different location there is no need for cookies, just interrogate the location and set the required conditions.

    You will need to identify what conditions need to be established for each page.
    basically each link (button) will be linked to it's own page, so we can just have something onclick as it is and then when the page loads have it contact the script and verify that it's associated button action (fade for the links_bw and class for the rightNav has been activated, and if not activate it.

    would that work?


    Still cant stop thinking that if not an IFRAME a frameset would be easier.
    I know... but the depreciated nature of it scares me for the future of the page :/
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #12
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    odd, because when i go here (http://www.enviromark.ca/head/YPPInclude.php) for example, click one of the right buttons, then click a left nav button, the right one which has the blue background keeps it instead of going back to having class="default"
    Code:
    function mClear(){
     if(LastID!=""){
      document.getElementById(LastID).className="default"
      LastID=""
      zxcCancelCookie();
     }
    }
    
    function zxcCancelCookie(){
     if (zxcCookie){
      var zxcc=new Date(new Date().getTime()-zxcDays*86400000).toGMTString();
      document.cookie=zxcCookie+'='+escape(' ')+';expires='+zxcc+';path=/;';
     }
    }
    basically each link (button) will be linked to it's own page, so we can just have something onclick as it is and then when the page loads have it contact the script and verify that it's associated button action (fade for the links_bw and class for the rightNav has been activated, and if not activate it.
    Think we are getting at crossed purposes

    see if the expiry time meets your requirement, if not we can come back to it.
    Last edited by vwphillips; 08-24-2007 at 05:14 AM.
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #13
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hey Vic,

    The cancelCookie worked for the mClear function Thanks

    The second point regarding the user re-opening the page and the class still being set to the last link opened is still happening. I tested it by going to http://www.enviromark.ca/head/indexInclude.php, clicking on "Media /Press", and then opening a fresh browser window and pasting in http://www.enviromark.ca/head/indexInclude.php into it. 'Media / Press' is still Blue (has a class other than 'default' applied to it) even if the link opened doesn't correspond.

    I tried playing with the expiry delay but all this does is have me guessing the average time between visits... which is in principle not a good coding / design avenue to go down.

    It almost seems like we're over-complicating this... should we even be using cookies for something like this? I mean essentially the page is reloading to a new url every time, so why not just have an onload="setClass('divID','class')" function on the actual .php page being loaded instead of an onclick mClick() function?
    Last edited by canadianjameson; 08-24-2007 at 10:10 PM.
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #14
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    It almost seems like we're over-complicating this... should we even be using cookies for something like this? I mean essentially the page is reloading to a new url every time, so why not just have an onload="setClass('divID','class')" function on the actual .php page being loaded instead of an onclick mClick() function?
    08-24-2007 04:09 AM
    this is what I was referring to in post 10

    Opps as each page has a different location there is no need for cookies, just interrogate the location and set the required conditions.
    I must have miss understood your response to the suggestion.

    I am finding the different threads on this project confusing can we use this thread to address all outstanding project elements?
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #15
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Just would like to point out that this code is unnecessary long.
    Code:
    document.getElementById(obj.id).className="whatever";
    This could be simplified to:
    Code:
    obj.className="whatever";
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  
    Page 1 of 4 123 ... LastLast

    Posting Permissions

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