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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Callback on DOM element attribute modification

    Hello all,

    Is anyone familiar with a method to receive notification/callback when a script is modifying a DOM attribute?

    I want to write code that tracks a certain document element, and notifies me (using some callback method) if one of the other page' scripts (which are out of my control) modifies one of the element's attributes.

    I can partially do that by overriding the setAttribute function, but it doesn't help me if the script accesses the attribute directly.

    Any help?

    Thanks in advance,
    Yoav

  • #2
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    set up a function to monitor the attribute in question and then notify yourself when it
    chnages


    http://www.java2s.com/Code/JavaScrip...uteExample.htm

    Code:
    <html>
    <body>
    <script language="JavaScript">
    function function1(){
        var m = document.getElementById("myDiv").getAttribute("id");
        alert(m);
    }
    </script>
    <div id="myDiv">This is a div element</div>
    <input type="button" value="Get id attribute value" onclick="function1();">
    </body>
    </html>

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, try this
    uggs

  • #6
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks TinyScript for your reply, but my problem is tracking down attributes that do not have modification events.

    for example, I'd like to be notified when a certain image's src attribute was modified (as soon as it is modified, not when it is reloaded)


  •  

    Tags for this Thread

    Posting Permissions

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