Example of creating a page for a simple URL encode
Copy the code below and create an index.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Encoder and Decoder</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 10px;
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>URL Encoder and Decoder</h1>
<label for="urlInput">Enter URL:</label>
<input type="text" id="urlInput" placeholder="Enter URL to encode or decode">
<button onclick="encodeURL()">Encode URL</button>
<button onclick="decodeURL()">Decode URL</button>
<h2>Result:</h2>
<p id="result"></p>
<script>
function customEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[()]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
function customDecodeURIComponent(str) {
return decodeURIComponent(str.replace(/(%[0-9A-Fa-f]{2})+/g, function(match) {
return String.fromCharCode(parseInt(match.substring(1), 16));
}));
}
function encodeURL() {
var urlInput = document.getElementById("urlInput").value;
var encodedUrl = customEncodeURIComponent(urlInput);
document.getElementById("result").innerHTML = encodedUrl;
}
function decodeURL() {
var urlInput = document.getElementById("urlInput").value;
var decodedUrl = customDecodeURIComponent(urlInput);
document.getElementById("result").innerHTML = decodedUrl;
}
</script>
</body>
</html>
The site demo is here