Created
July 9, 2025 08:29
-
-
Save OrtonLin/d125fbc0cda63ba2100bc362ba746959 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>URL Encode / Decode Tool</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
max-width: 600px; | |
margin: 40px auto; | |
padding: 20px; | |
background-color: #f8f9fa; | |
border-radius: 10px; | |
box-shadow: 0 0 10px rgba(0,0,0,0.1); | |
} | |
textarea { | |
width: 100%; | |
height: 100px; | |
margin-bottom: 10px; | |
font-size: 16px; | |
} | |
button { | |
padding: 10px 20px; | |
margin-right: 10px; | |
font-size: 16px; | |
} | |
.label { | |
margin-top: 20px; | |
font-weight: bold; | |
} | |
</style> | |
</head> | |
<body> | |
<h2>URL Encode / Decode 工具</h2> | |
<label for="input">輸入原始文字:</label> | |
<textarea id="input" placeholder="請輸入文字..."></textarea> | |
<div> | |
<button onclick="encode()">Encode</button> | |
<button onclick="decode()">Decode</button> | |
</div> | |
<div class="label">結果:</div> | |
<textarea id="output" readonly></textarea> | |
<script> | |
function encode() { | |
const input = document.getElementById('input').value; | |
const encoded = encodeURIComponent(input); | |
document.getElementById('output').value = encoded; | |
} | |
function decode() { | |
const input = document.getElementById('input').value; | |
try { | |
const decoded = decodeURIComponent(input); | |
document.getElementById('output').value = decoded; | |
} catch (e) { | |
document.getElementById('output').value = '❌ Decode 錯誤:可能不是合法的 URL 編碼'; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment