Firefox中的文本框的onpropertychange? [英] onpropertychange for a textbox in Firefox?

查看:110
本文介绍了Firefox中的文本框的onpropertychange?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



下面是一个例子:

如何处理Firefox中的文本框的 onpropertychange / p>

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


解决方案

有两种模拟方式onpropertychange事件,如上所述的Mutation事件应该在现代浏览器中同样工作,而object.watch非标准方法将为旧版本的FF& 3。



请参阅MDC上的文档。



Object.watch



突变事件


How to handle the onpropertychange for a textbox in Firefox using JavaScript?

Below is an example:

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

解决方案

There are two ways to mimic the onpropertychange event, Mutation events as mentioned above that should work equally across modern browsers and the "object.watch" non-standard method that will provide support for old versions of FF < 3.

See documentation on MDC.

Object.watch

Mutation events

这篇关于Firefox中的文本框的onpropertychange?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆