Results 1 to 2 of 2

Thread: Watching variables

  1. #1
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default Watching variables

    I was just wondering how you have basically an event attached to a variable. So when it changes a function is called. Can it be done, and if so is it cross browser?

  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

    You can use a poll, which is a looping function (using setInterval or setTimeout) that periodically checks the value of the variable involved and then does something if it changes. However, in almost all cases, it is better to simply have the event or script code that changes the variable's value in the first place also do whatever needs to be done when that variable is changed.
    - 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
  •