Js monitors the status of text boxes in real time. The compatibility of the methods here is not very good. We recommend that you refer to the previous articles in the script house.
The Code is as follows:
Script
// Function executed when the status changes
Function handle ()
{
Document. getElementById ('msg '). innerHTML = document. getElementById ('txt'). value;
}
// If ("\ v" = "v") returns true only under IE, including IE8
// If (/msie/I. test (navigator. userAgent) can also be effectively determined
If ("\ v" = "v "){
// The IE listens to the text box and assigns a function. The function name cannot contain parentheses.
Document. getElementById ('txt '). onpropertychange = handle;
} Else {
// Google Chrome uses the Add event function to add an event to the text box and assign the event to be executed. The method name cannot be enclosed by brackets.
Document. getElementById ('txt '). addEventListener ("input", handle );
}
Script