<script language="vbscript">
function urlencoding(vstrin)
dim i,strreturn
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
strreturn = strreturn & thischr
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
urlencoding = strreturn
end function
</script>
<script language=javascript>
function O9(id) {window.alert("profile.cgi?action=show&member="+urlencoding(id));}
O9("中文")
</script>
function urlencoding(vstrin)
dim i,strreturn
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
strreturn = strreturn & thischr
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
urlencoding = strreturn
end function
</script>
<script language=javascript>
function O9(id) {window.alert("profile.cgi?action=show&member="+urlencoding(id));}
O9("中文")
</script>
function O9(id) {window.open("profile.cgi?action=show&member="+escape(id));}
O9("中文")
</script>
转换的格式不对,我用escape(id)转换“中文”两个字
代码为:%u5C0F%u9EA6
而我需要的是:%D6%D0%CE%C4
上面vbscript出来的正确!但我只能用javascript!
不知道有没有办法,谢谢!
<script language=javascript>
function O9(id) {window.alert("profile.cgi?action=show&member="+UrlEncode(id));}
window.onload=new Function('O9("中文Abc")');
</script>