Tus*_*aru 3 javascript firefox events dom mutation-events
如何onpropertychange使用JavaScript 处理Firefox中的文本框?
以下是一个例子:
var headerBGColorTextBox = document.getElementById('<%= tbHeaderBGColor.ClientID %>');
if (headerBGColorTextBox != null) {
headerBGColorTextBox.pluggedElement = document.getElementById('<%= trHeaderBG.ClientID %>');
headerBGColorTextBox.onpropertychange = function() {
alert('function called');
if (event.propertyName == 'style.backgroundColor' && event.srcElement.pluggedElement != null)
alert(event.propertyName);
event.srcElement.pluggedElement.style.backgroundColor = event.srcElement.style.backgroundColor;
};
}
Run Code Online (Sandbox Code Playgroud)
有两种模仿onpropertychange事件的方法,如上所述的Mutation事件应该在现代浏览器中同等地工作,而"object.watch"非标准方法将为旧版本的FF <3提供支持.
请参阅有关MDC的文档.