ASP代码中用VBS调用JS脚本引擎还原经过encodeURI编码过的URL地址
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ASP代码中用VBS调用JS脚本引擎还原经过encodeURI编码过的URL地址</title>
</head>
<body>
<%
Function JSdecodeURL(ByVal oriurl)
Err.Clear
on error resume next
dim sobj,outputstr
set sobj=createObject("MSScriptControl.ScriptControl")
sobj.Language="JavaScript"
outputstr=sobj.Eval("decodeURI("""&oriurl&""")")
set sobj=Nothing
If Err.Number=0 then JSdecodeURL=outputstr else JSdecodeURL=oriurl
End Function
if request.servervariables("QUERY_STRING") <>"" then
Response.Write(JSdecodeURL(request.servervariables("QUERY_STRING") ))
else
Response.Write(JSdecodeURL("http://www.blueidea.com/?%E8%93%9D%E8%89%B2%E7%90%86%E6%83%B3"))
end if
%>
</body>
</html>
将上面代码保存test.asp文件上传到自己网站根目录,地址栏输入:
http://www.xxx.com/test.asp?一网传媒CODE
【备注】:
其它JS函数能返回值的,也可以在ASP中通过VBS这样调用。