Notification texts go here Contact Us Buy Now!

Conversor de HTML a texto plano para tu blog

jesanre

Puedes lograrlo utilizando JavaScript en el lado del cliente para procesar el HTML ingresado por el usuario y mostrar el resultado en otra área de texto. Aquí hay un ejemplo simple utilizando HTML y JavaScript:

<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Conversor HTML a Texto Plano</title>
</head>
<body>

  <label for="htmlInput">Introduce tu código HTML:</label>
  <textarea id="htmlInput" rows="5" cols="50"></textarea>

  <button onclick="convertirHTML()">Convertir a Texto Plano</button>

  <label for="plainTextOutput">Texto Plano Resultante:</label>
  <textarea id="plainTextOutput" rows="5" cols="50" readonly></textarea>

  <script>
    function convertirHTML() {
      var htmlInput = document.getElementById("htmlInput").value;
      var parser = new DOMParser();
      var doc = parser.parseFromString(htmlInput, 'text/html');
      var plainText = doc.body.textContent || "";
      document.getElementById("plainTextOutput").value = plainText;
    }
  </script>

</body>
</html>


Este código HTML proporciona un área de texto para que el usuario introduzca su código HTML, un botón que al hacer clic ejecuta la función convertirHTML(), y otro área de texto que mostrará el resultado en texto plano. La función convertirHTML() utiliza el DOMParser para analizar el HTML y extraer el texto del cuerpo del documento.

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.