简体   繁体   中英

Web browser control: Detecting changes in form content

A form contains many elements, such as labels, Textbox, radio options box etc

How do you detect the user has changed a textbox input value, or has choosen a radio option within the content of a web browser control? (not the winform itself).

Do you handle a winform event for when the mouse clicked or keyboard keys pressed? or is there a better way to detect changes in the web browser content?

There are "quick and easy" ways, but IMHO, a better way is to load the state of the form into javascript variables (on load), and then compare only the elements you are interested in, when navigating away, or whatever.

For example, there may be some fields that aren't so relevant (say, a different value in a minor drop-down box) but some that are very important (ie the contents of this message box).

It's fairly trivial to do anyway; just check the values you have currently (on the given event you are capturing, ie browser close) and then compare them with the ones you saved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM