www.webdeveloper.com
Results 1 to 7 of 7

Thread: Help with DOM event element.style.display

  1. #1
    Join Date
    Apr 2009
    Posts
    3

    Help with DOM event element.style.display

    I am have trouble to find what event will be fired if i modify an element.style.display. The function i want o achieve is to run some script if an element.style.display is changed. I used onpropertychange for IE, can anybody help me to find something for firefox? Thanks.

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    it is said that firefox have some support for MutationEvents but can't understand how it is used
    http://www.sitepoint.com/forums/showthread.php?t=531881

  3. #3
    Join Date
    Apr 2009
    Posts
    3
    Quote Originally Posted by ZeroKilled View Post
    it is said that firefox have some support for MutationEvents but can't understand how it is used
    http://www.sitepoint.com/forums/showthread.php?t=531881
    Can anyone be more specific? I have looked the mutation event but none of it can fill-full my need.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    window.onload=function() {
    document.getElementById("xxxx").addEventListener("DOMAttrModified", changed, false);
    };
    
    function changed(e) {
    alert(e.attrName+' attribute change occured');
    }
    </script>
    
    <style type="text/css">
    * {margin:0;padding:0;}
    </style>
    
    </head>
    <body>
    <div id="xxxx" style="display:none;">Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.</div>
    <button type="button" onclick="document.getElementById('xxxx').style.display='block';">change style</button>
    </body>
    </html>
    Last edited by Fang; 04-28-2009 at 08:10 AM.

  5. #5
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    Fang,
    thanks for showing an example! i has read a brief about MutationEvent but is the very first time i see it working.

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Did a similar one earlier: DOMSubtreeModified

    Changed example to show attribute changed.
    Last edited by Fang; 04-28-2009 at 08:11 AM.

  7. #7
    Join Date
    Apr 2009
    Posts
    3
    Quote Originally Posted by Fang View Post
    Did a similar one earlier: DOMSubtreeModified

    Changed example to show attribute changed.
    Thanks Fang that is exactly what i needed. Now problem resolved. I am using both to listen for a span's textcontent change and its style change.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles