...

View Full Version : Callback on DOM element attribute modification



yoav
04-15-2009, 10:13 AM
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

TinyScript
04-15-2009, 05:07 PM
set up a function to monitor the attribute in question and then notify yourself when it
chnages


http://www.java2s.com/Code/JavaScriptReference/Javascript-Methods/getAttributeExample.htm



<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>

fhbdf
04-15-2009, 09:43 PM
http://www.*************

fhbdf
04-15-2009, 09:44 PM
http://www.****************

fhbdf
04-15-2009, 09:46 PM
well, try this
uggs (http://www.*************)

yoav
04-16-2009, 09:18 AM
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)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum