Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-15-2009, 10:13 AM   PM User | #1
yoav
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
yoav is an unknown quantity at this point
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
yoav is offline   Reply With Quote
Old 04-15-2009, 05:07 PM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
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>
TinyScript is offline   Reply With Quote
Old 04-15-2009, 09:43 PM   PM User | #3
fhbdf
New to the CF scene

 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
fhbdf is an unknown quantity at this point
http://www.*************
fhbdf is offline   Reply With Quote
Old 04-15-2009, 09:44 PM   PM User | #4
fhbdf
New to the CF scene

 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
fhbdf is an unknown quantity at this point
http://www.****************
fhbdf is offline   Reply With Quote
Old 04-15-2009, 09:46 PM   PM User | #5
fhbdf
New to the CF scene

 
Join Date: Apr 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
fhbdf is an unknown quantity at this point
well, try this
uggs
fhbdf is offline   Reply With Quote
Old 04-16-2009, 09:18 AM   PM User | #6
yoav
New to the CF scene

 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
yoav is an unknown quantity at this point
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)
yoav is offline   Reply With Quote
Reply

Bookmarks

Tags
attribute, callback, dom, modification

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.