Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: Why does my script repeat once ????

  1. #1
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Why does my script repeat once ????

    Hello all ,

    The following script when your mouse over the text it stretches out a little but when you move your mouse out t stratches back !!!
    But all that only repeats once for some reson can anyone tell me what's wrong

    <html>
    <head>
    <body>
    <span id="zx" onmouseover="e()" onmouseout="asd()">I used to</span><br>
    <span id="cv" onmouseover="w()">Hate</span><br>
    <span id="bn" onmouseover="q()">You</span><br>


    <script>
    var a = 0
    var aa = 10
    function e() {
    if (a<aa) {
    a++
    document.getElementById('zx').style.letterSpacing=a
    pokli = setTimeout("e()",50)}
    }

    var d = 9
    var dd = 0
    function asd() {
    if (d>dd) {
    d--
    document.getElementById('zx').style.letterSpacing=d
    aoposido = setTimeout("asd()",50)}
    }
    </script>


    <script>
    var b = 0
    var bb = 10
    function w() {
    if (b<bb) {
    b++
    document.getElementById('cv').style.letterSpacing=b
    askli = setTimeout("w()",50)}
    }
    </script>
    <script>
    var c = 0
    var cc = 10
    function q() {
    if (c<cc) {
    c++
    document.getElementById('bn').style.letterSpacing=c
    asop = setTimeout("q()",50)}
    }
    </script>
    </body>
    </head>
    </html>

    It was just a test so don't expect so much and also just focus on the I used to part on the script seeing as how it's the only string with the mouseout and mouseover events set....

    Thanks for your time

  2. #2
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So c'mon people i need some and some here!!!

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    1. Your <body> tag DOES NOT belong in your <head>.
    2. You don't need seperate script tags for each function.
    3. Use the type="text/javascript" attribute on your <script> tags
    Code:
    <script type="text/javascript">
    var a = 0
    var aa = 10
    function e() {
    if (a<aa) {
    a++
    document.getElementById('zx').style.letterSpacing=a
    pokli = setTimeout("e()",50)}
    }
    
    var d = 9
    var dd = 0
    function asd() {
    if (d>dd) {
    d--
    document.getElementById('zx').style.letterSpacing=d
    aoposido = setTimeout("asd()",50)}
    }
    
    var b = 0
    var bb = 10
    function w() {
    if (b<bb) {
    b++
    document.getElementById('cv').style.letterSpacing=b
    askli = setTimeout("w()",50)}
    }
    var c = 0
    var cc = 10
    function q() {
    if (c<cc) {
    c++
    document.getElementById('bn').style.letterSpacing=c
    asop = setTimeout("q()",50)}
    }
    </script>
    You should try to validate your pages as well.
    - Mike

  4. #4
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for replying,

    But my script still does the same thing, the body can be in between, and i just kept repeating the functions between new script tags because it is easier for me to manage it that way

    So do you know what is wrong???

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The following script when your mouse over the text it stretches out a little but when you move your mouse out t stratches back !!!
    <span id="zx" onmouseover="e()" onmouseout="asd()">I used to</span><br>
    Remove that.
    - Mike

  6. #6
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Lol you got it wrong i was just emphazing on what i can do, that was intended to do that but the whole thing just happens once.

    What i mean is that you put your mouse on it and it stretches out take your mouse out it stretches back but put your mouse on again and it does not work, that is the issue

    Got any idea??

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You did not clear your initial timeout when you mouseover for the second time. The two timeouts are conflicting with each other. Use clearTimeout(timeid) to remove timeouts.
    - Mike

  8. #8
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm i thought that might be the case but in which way should i do it exactly while you reply i will try on my own...

  9. #9
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried to set the timeout accordingly but failed to do so,
    Mind givin me a hand???

  10. #10
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well it seems that in general i do not know how to properly clearTimeout's on every one of my scripts (the ones with timeouts on them) do not repeat a second time.

    So it would be VERY appreciated if you could help me

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
  •