0

I have a TEXTAREA that is created through an external JavaScript. I am writing new script to detect when the contents are changed. DOM events like "change" and "blur" do not work, since the change is initiated by the other script. I do not have the ability to read/modify the external script.

Any ideas?

1 Answers1

1

If you want full cross-browser support, you will simply have to set up a polling interval and compare the contents each time to what you saw the last time. DOM mutation events aren't going to cut it.

Have fun.

ErikE
  • 48,881
  • 23
  • 151
  • 196
  • And DOM mutation events are already deprecated before even had been implemented in all major browsers – A. Wolff Jun 06 '13 at 17:10
  • That, too! I heard they were not to be relied on. – ErikE Jun 06 '13 at 17:11
  • An other way could be to extend some jquery method(s) if the external plugin use it to update textarea value. For example, OP could look here even there it is for DOM change: http://stackoverflow.com/a/15973530/1414562 – A. Wolff Jun 06 '13 at 17:13
  • Just FYI, DOM4 [mutation observers](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) are the replacement for deprecated DOM3 mutation events, but they're not widely supported, so your advice is necessary for cross-browser support. – apsillers Jun 06 '13 at 17:13
  • @roasted That's a big *if*. Yes, *if* the other script uses jQuery then perhaps you could tweak jQuery to let you know when the value is changed. – ErikE Jun 06 '13 at 17:15
  • @ErikE as you said: a big **IF** – A. Wolff Jun 06 '13 at 17:17