<SCRIPT>
VaR encodeuri = function (unzipstr, iscusencode ){
If (iscusencode ){
VaR ziparray = new array ();
VaR zipstr = "";
VaR lens = new array ();
For (VAR I = 0; I <unzipstr. length; I ++ ){
VaR AC = unzipstr. charcodeat (I );
Zipstr + = ac;
Lens = Lens. Concat (AC. tostring (). Length );
}
Ziparray = ziparray. Concat (zipstr );
Ziparray = ziparray. Concat (lens. Join ("O "));
Return ziparray. Join ("N ");
} Else {
// Return encodeuri (unzipstr );
VaR zipstr = "";
VaR strspecial = "! "" # $ % & '() * +,/:; <=>? [] ^ '{| }~ % ";
VaR TT = ""; For (VAR I = 0; I <unzipstr. length; I ++ ){
VaR CHR = unzipstr. charat (I );
VaR c = stringtoascii (CHR );
Tt + = CHR + ":" + C + "N ";
If (parseint ("0x" + C)> 0x7f ){
Zipstr + = encodeuri (unzipstr. substr (I, 1 ));
} Else {
If (CHR = "")
Zipstr + = "+ ";
Else if (strspecial. indexof (CHR )! =-1)
Zipstr + = "%" + C. tostring (16 );
Else
Zipstr + = CHR;
}
}
Return zipstr;
}
} VaR decodeuri = function (zipstr, iscusencode ){
If (iscusencode ){
VaR ziparray = zipstr. Split ("N ");
VaR zipsrcstr = ziparray [0];
VaR ziplens;
If (ziparray [1]) {
Ziplens = ziparray [1]. Split ("O ");
} Else {
Ziplens. Length = 0;
}
VaR uzipstr = "";
For (var j = 0; j <ziplens. length; j ++ ){
VaR charlen = parseint (ziplens [J]);
Uzipstr + = string. fromcharcode (zipsrcstr. substr (0, charlen ));
Zipsrcstr = zipsrcstr. Slice (charlen, zipsrcstr. Length );
}
Return uzipstr;
} Else {
// Return decodeuri (zipstr );
VaR uzipstr = ""; For (VAR I = 0; I <zipstr. length; I ++ ){
VaR CHR = zipstr. charat (I );
If (CHR = "+ "){
Uzipstr + = "";
} Else if (CHR = "% "){
VaR ASC = zipstr. substring (I + 1, I + 3 );
If (parseint ("0x" + ASC)> 0x7f ){
Uzipstr + = decodeuri ("%" + ASC. tostring () + zipstr. substring (I + 3, I + 9). tostring ());;
I + = 8;
} Else {
Uzipstr + = asciitostring (parseint ("0x" + ASC ));
I + = 2;
}
} Else {
Uzipstr + = CHR;
}
}
Return uzipstr;
}
} VaR stringtoascii = function (STR ){
Return Str. charcodeat (0). tostring (16 );
} VaR asciitostring = function (asccode ){
Return string. fromcharcode (asccode );
}
</SCRIPT>
AboveCodeThe effect of server. urlencode written in C # is the same. If you need to input Chinese characters on the client, try this function.
Usage: "http://www.fanchuanbook.com/search.aspx? Q = "+ encodeuri (Q, false)
<SCRIPT>
var url = "{phpcms_path} yczx/searchcy. php? Ordertype = 1 & search = 1 & searchtype = content & catid = 183 & KEYWORDS = "+ encodeuri (" {$ title }");
var encode = encodeuri ("{$ title}");
document. write ('');
document. write ('click to view all stages of the venue ');