Created
January 11, 2013 05:28
-
-
Save santosh/4508179 to your computer and use it in GitHub Desktop.
JavaScript: URL dencoder is an URL encoder and decoder. The core is entirely written in JavaScript.
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 dir="ltr" lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<meta name="viewport" content="width=device-width"> | |
<title>URL Decoder/Encoder</title> | |
<link rel="stylesheet" type="text/css" href="style.css" media="screen" /> | |
</head> | |
<body> | |
<form onsubmit="return false;"> | |
<h1>URL Decoder/Encoder</h1> | |
<textarea placeholder="Write your stuffs here" cols="80" rows="20" id="dencoder"></textarea> | |
<div> | |
<input type="button" onclick="decode()" value="Decode"> | |
<input type="button" onclick="encode()" value="Encode"> | |
</div> | |
</form> | |
<script type="text/javascript" src="dencoder.js"></script> | |
</body> | |
</html> |
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
// define the id of the textarea carefully | |
function encode() { | |
var obj = document.getElementById('dencoder'); | |
var unencoded = obj.value; | |
obj.value = encodeURIComponent(unencoded); | |
} | |
// define the id of the textarea carefully | |
function decode() { | |
var obj = document.getElementById('dencoder'); | |
var encoded = obj.value; | |
obj.value = decodeURIComponent(encoded.replace(/\+/g, " ")); | |
} |
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
form { | |
margin: 0; | |
} | |
h1 { | |
font-family: Arial, sans-serif; | |
line-height: 0.85em; | |
margin-bottom: 0.33em; | |
padding-bottom: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment