Results 1 to 3 of 3

Thread: Help with a mouse trail script

  1. #1
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default Help with a mouse trail script

    1) Script Title: Circling text trail

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...circletext.htm

    3) Describe problem:

    It isnt really a problem just need some help or advice. I am a rookie at Javascript. What I am trying to accomplish is to use this script but only after an onClick (as in I want the effect but only after someone clicks an href or button). Can anyone help me to make this happen? At line 128 it has an (onload, init) is there a way to point this to an onClick. Any help is appreciated.


    Thanks in advance.

  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

    At the end of the script:

    Code:
    if (window.addEventListener){
     window.addEventListener('load', init, false);
     document.addEventListener('mouseover', mouse, false);
     document.addEventListener('mousemove', mouse, false);
      if (/Apple/.test(navigator.vendor))
       window.addEventListener('scroll', ascroll, false);
    }
    else if (window.attachEvent){
     window.attachEvent('onload', init);
     document.attachEvent('onmousemove', mouse);
    };
    
    })();
    Make it like so:

    Code:
    if (window.addEventListener){
     //window.addEventListener('load', init, false);
     document.addEventListener('mouseover', mouse, false);
     document.addEventListener('mousemove', mouse, false);
      if (/Apple/.test(navigator.vendor)) // Safari only
       window.addEventListener('scroll', ascroll, false);
    }
    else if (window.attachEvent){
     //window.attachEvent('onload', init);
     document.attachEvent('onmousemove', mouse);
    };
    window.initcircletext = init;
    })();
    Now it won't start onload and you may have a link to click to start the effect like so:

    HTML Code:
    <a href="#" onclick="initcircletext(); initcircletext = function(){}; return false;">Start It</a>
    In fact, you can have as many of these as you like. However, only the first one clicked will do anything.

    The text:

    Start It
    in the above may be replaced with any text of your choosing. You could even substitute an img tag there.
    - John
    ________________________

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

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    itivae (02-04-2012)

  4. #3
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    Thank You. I will give that a try.

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
  •