当前位置: 移动技术网 > IT编程>开发语言>Asp > 在asp中使用js的encodeURIComponent方法

在asp中使用js的encodeURIComponent方法

2017年12月08日  | 移动技术网IT编程  | 我要评论
大家知道,在js里encodeuricomponent 方法是一个比较常用的编码方法,但因工作需要,在asp里需用到此方法,查了好多资料,没有很好的方法,最后用了下面这个方法,基本解决了问题。
复制代码 代码如下:

<%
function aspencodeuricomponent(sstr)
aspencodeuricomponent = myencodeuricomponent(sstr)
%>
<script language="javascript" type="text/javascript" runat="server">
function myencodeuricomponent(sstr){
return encodeuricomponent(sstr);
}
</script>
<%
end function
%>

附注:

encodeuricomponent 方法
将文本字符串编码为一个统一资源标识符 (uri) 的一个有效组件。

encodeuricomponent(encodeduristring)

必选的 encodeduristring 参数代表一个已编码的 uri 组件。

说明
encodeuricomponent 方法返回一个已编码的 uri。如果您将编码结果传递给 decodeuricomponent,那么将返回初始的字符串。因为 encodeuricomponent 方法对所有的字符编码,请注意,如果该字符串代表一个路径,例如 /folder1/folder2/default.html,其中的斜杠也将被编码。这样一来,当该编码结果被作为请求发送到 web 服务器时将是无效的。如果字符串中包含不止一个 uri 组件,请使用 encodeuri 方法进行编码。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网