開發中發現須要進行URL的編解碼,每次百度出來的還帶廣告並且比較慢,寫了一個本地的工具,比較簡單,但願對你們有幫助。javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Author: Kang, Leo Date: 2015-8-19 Email: kangyi@staff.weibo.com QQ: 531155260 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> textarea{ height:200px; width:100%; margin:5px; } input{ height:40px; width:100%; margin:5px; background:#00CED1} .button2{ height:40px; width:100%; margin:5px; background:#00FF7F} </style> </head> <body> <script type="text/javascript"> function funDecode(){ var url = document.getElementById("url_input").value; document.getElementById("url_decoded_input").value = decodeURIComponent(url.replace(/\+/g, " ")); } function funEncode(){ var url = document.getElementById("url_decoded_input").value; document.getElementById("url_encode_input").value = encodeURIComponent(url).replace(/'/g,"%27").replace(/"/g,"%22"); } </script> <form name="myForm"> <h4>須要解碼的URL:</h4> <textarea id="url_input" name="input" rows="14" maxlength="32768"></textarea> <br /> <input type="button" name="urlDecodeInput" value="點擊開始URL解碼" onclick="funDecode()" /> <br /> <h4>解碼後的URL或者待編碼的URL:</h4> <textarea id="url_decoded_input" name="input" rows="14" maxlength="32768"></textarea> </form> <form name="myForm"> <input type="button" name="urlEncodeButton" class="button2" value="點擊開始URL編碼" onclick="funEncode()" /> <br /> <h4>編碼後的URL:</h4> <textarea id="url_encode_input" name="input" rows="14" maxlength="32768"></textarea> </form> </body> </html>