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.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post

    problem with fade toggle

    hi - the following script works fine except that when the "link" (not really a link, a span of type that triggers on onclick fade) is clicked before the transition is finished playing, freezes the visibility. however, i accidentally found out that clicking the other span quickly will start the opposing fade (which is what i want). i assume it has something to do with the .stop but i haven't been able to correct it myself. any help would be greatly appreciated.

    <HTML>
    <HEAD>
    </HEAD>

    <BODY>
    <SPAN ID="CL1" onclick="curObj = I1; toggle()">CL1</SPAN>
    <SPAN ID="CL2" onclick="curObj = I2; toggle()">CL2</SPAN>

    <DIV ID="I1" STYLE="visibility: hidden; width: 100%; filter:blendTrans(duration=1)">i1</DIV>

    <DIV ID="I2" STYLE="visibility: hidden; width: 100%; filter:blendTrans(duration=1)">i2</DIV>

    <SCRIPT LANGUAGE="JavaScript">
    var curObj;
    function toggle() {
    if (curObj.filters(0).status == 2) {
    curObj.filters(0).Stop();
    if (curObj.style.visibility == "hidden")
    curObj.style.visibility = "visible";
    else
    curObj.style.visibility = "hidden";
    window.setTimeout("toggle()", 1);
    }
    curObj.filters(0).Apply();
    if (curObj.style.visibility == "hidden")
    curObj.style.visibility = "visible";
    else
    curObj.style.visibility = "hidden";
    curObj.filters(0).Play();
    }

    </SCRIPT>
    </BODY>
    </HTML>

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post
    bump

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by subhailc
    bump
    A little impatient.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this simplified code:

    Code:
    <HTML>
    <HEAD>
    </HEAD>
    
    <BODY>
    <SPAN ID="CL1" onclick="toggle(getElementById('I1'))">CL1</SPAN>
    <SPAN ID="CL2" onclick="toggle(getElementById('I2'))">CL2</SPAN>
    
    <DIV ID="I1" STYLE="visibility: hidden; width: 100%; filter:blendTrans(duration=1)">i1</DIV>
    
    <DIV ID="I2" STYLE="visibility: hidden; width: 100%; filter:blendTrans(duration=1)">i2</DIV>
    
    <SCRIPT LANGUAGE="JavaScript">
    function toggle(curObj) {
    if (curObj.filters(0).status == 2) {
    curObj.filters(0).Stop();
    if (curObj.style.visibility == "hidden")
    curObj.style.visibility = "visible";
    else
    curObj.style.visibility = "hidden";
    window.setTimeout("toggle()", 1);
    }
    curObj.filters(0).Apply();
    if (curObj.style.visibility == "hidden")
    curObj.style.visibility = "visible";
    else
    curObj.style.visibility = "hidden";
    curObj.filters(0).Play();
    }
    
    </SCRIPT>
    </BODY>
    </HTML>
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

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