⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 urlencode.js

📁 多多网店系统v3.01 完全免费可用版-功能简介: 支持多模板皮肤色切换[8套] 支持按商品特性[推荐商品/特价商品/新品分类]浏览 支持按商品类别浏览 支持单件商品用支付宝交易按钮直接支付订
💻 JS
字号:
/*
below is function encodeURI
*/
/* *************************** 
** Most of this code was kindly 
** provided to me by 
** Andrew Clover (and at doxdesk dot com) 
** http://and.doxdesk.com/ ; 
** in response to my plea in my blog at 
** http://worldtimzone.com/blog/date/2002/09/24 
** It was unclear whether he created it. 
*/ 
function utf8(wide) { 
var c, s; 
var enc = ""; 
var i = 0; 
while(i<wide.length) { 
c= wide.charCodeAt(i++); 
// handle UTF-16 surrogates 
if (c>=0xDC00 && c<0xE000) continue; 
if (c>=0xD800 && c<0xDC00) { 
if (i>=wide.length) continue; 
s= wide.charCodeAt(i++); 
if (s<0xDC00 || c>=0xDE00) continue; 
c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000; 
} 
// output value 
if (c<0x80) enc += String.fromCharCode(c); 
else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F)); 
else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F)); 
else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F)); 
} 
return enc; 
} 

var hexchars = "0123456789ABCDEF"; 

function toHex(n) { 
return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF); 
} 

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"; 

function encodeURIComponentNew(s) { 
var s = utf8(s); 
var c; 
var enc = ""; 
for (var i= 0; i<s.length; i++) { 
if (okURIchars.indexOf(s.charAt(i))==-1) 
enc += "%"+toHex(s.charCodeAt(i)); 
else 
enc += s.charAt(i); 
} 
return enc; 
} 

function URLEncode(fld) 
{ 
if (fld == "") return false; 
var encodedField = ""; 
var s = fld; 
if (typeof encodeURIComponent == "function") 
{ 
// Use javascript built-in function 
// IE 5.5+ and Netscape 6+ and Mozilla 
encodedField = encodeURIComponent(s); 
} 
else 
{ 
// Need to mimic the javascript version 
// Netscape 4 and IE 4 and IE 5.0 
encodedField = encodeURIComponentNew(s); 
} 
//alert ("New encoding: " + encodeURIComponentNew(fld) + 
// "\n escape(): " + escape(fld)); 
return encodedField; 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -