Este artículo describe el método de funciones personalizadas para implementar IE7 e IE8 incompatibles con funciones de recorte en JS. Compártelo para su referencia. El método de implementación específico es el siguiente:
<html> <fead> <title> test </title> <script type = "text/javascript"> string.prototype.trim = function () {return this.replace (/(^/s*) | (/s*$)/g, "); } function check () {var str = document.getElementById ("prueba"). valor; alerta (str.trim ()); } </script> </head> <body> <center> <input id = "test" type = "text"/> <input id = "pero" type = "button" value = "check" onClick = "check ();"/> </center> </body> </html>Esto resuelve el problema de que JS no admite TRIM en IE.
Espero que este artículo sea útil para la programación de JavaScript de todos.