zoukankan      html  css  js  c++  java
  • URL编码和解码工具

    开发中发现需要进行URL的编解码,每次百度出来的还带广告而且比较慢,写了一个本地的工具,比较简单,希望对大家有帮助。

    <!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;
    100%;
    margin:5px;
    }
    
    input{
    height:40px;
    100%;
    margin:5px;
    background:#00CED1}
    
    .button2{
    height:40px;
    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>
    

      

  • 相关阅读:
    软件新人问题解答(一)
    项目上线流程
    面试题:如何测试登录功能
    软件测试人员在工作中如何运用Linux
    认识接口测试
    刚入职的新人如何快速了解公司业务
    软件测试人员每天的工作日常
    面试题分析(二)如何避免漏测
    [谨记]记线上事故并分析原因
    面试经验分享:遇到不会回答的问题怎么回答才好
  • 原文地址:https://www.cnblogs.com/kangyi/p/4742862.html
Copyright © 2011-2022 走看看