HTML code scrip for URL encoder

Created on 3 July, 2024 • 119 views • 1 minutes read

HTML code scrip for URL encoder

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <title>URL Encoder</title>

</head>

<body>

  <h1>URL Encoder</h1>

  <p>Enter the URL you want to encode:</p>

  <input type="text" id="urlInput" placeholder="Enter URL here">

  <button onclick="encodeURL()">Encode</button>

  <br>

  <p id="encodedURL"></p>


  <script>

    function encodeURL() {

      // Get the URL from the input field

      var url = document.getElementById("urlInput").value;


      // Encode the URL using JavaScript's encodeURIComponent function

      var encodedURL = encodeURIComponent(url);


      // Display the encoded URL in the designated paragraph

      document.getElementById("encodedURL").innerHTML = "Encoded URL: " + encodedURL;

    }

  </script>

</body>

</html>