Results 1 to 2 of 2

Thread: How can I make a script function disabled ??

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

    Default How can I make a script function disabled ??

    I want to use a hyperlinked text, linked with a script function that makes stoping functioning another script.
    Can you help me ?

  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

    It really depends on that 'another script' that you want to stop. A script can be stopped in a number of ways, some none too graceful. If you redefine one of its global variables to be out of range of what is expected or if you redefine one of its key functions, this should stop it, but often with errors and/or (depending upon what the script does) odd visual or other effects.

    If the script loops (via timeout) or reacts to events, you can often place a test into it:

    Code:
    function mainFunc(){
    if (mainFunc.stop)
    return;
    do whatever this script does
    }
    Then your link to stop it could be:

    HTML Code:
    <a href="#" onclick="mainFunc.stop=true;return false;">Stop</a>
    If it loops via interval, you may need to clear the interval as well, and this is usually a good idea anyway where intervals are involved and the script needs to stop. Sometimes, even if it loops via timeout, that needs to be cleared too. To be more specific, I would need to see more details on the actual setup, preferably a link to the live page.
    - 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
  •