在asp中使用js的encodeURIComponent方法
来源:asp之家 时间:2012-11-30 20:05:53
大家知道,在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 方法进行编码。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
php通过获取头信息判断图片类型的方法
七个生态系统核心库[python自学收藏]
![](https://img.aspxhome.com/file/2023/9/101699_0s.jpg)
python 列表,数组和矩阵sum的用法及区别介绍
![](https://img.aspxhome.com/file/2023/7/127847_0s.jpg)
opencv读取视频并保存图像的方法
![](https://img.aspxhome.com/file/2023/6/105296_0s.jpg)
Pytorch 和 Tensorflow v1 兼容的环境搭建方法
![](https://img.aspxhome.com/file/2023/1/93741_0s.png)
Python线性回归实战分析
![](https://img.aspxhome.com/file/2023/5/65055_0s.png)
php验证session无效的解决方法
桌面中心(二)数据库写入
JavaScript 数组的 uniq 方法
opencv3/C++图像像素操作详解
![](https://img.aspxhome.com/file/2023/1/105061_0s.jpg)
ubuntu下简单配置mysql数据库
Clion、IEDA、pycharm的一些简单设置步骤(设置中文菜单、输出中文、字体大小、背景颜色主题)
![](https://img.aspxhome.com/file/2023/8/130888_0s.png)
python使用递归的方式建立二叉树
![](https://img.aspxhome.com/file/2023/7/120367_0s.png)
脆弱的用户体验
matplotlib.pyplot.matshow 矩阵可视化实例
![](https://img.aspxhome.com/file/2023/6/92006_0s.jpg)
SQL常用的四个排序函数梳理
![](https://img.aspxhome.com/file/2023/6/124836_0s.png)
python实现简易连点器
![](https://img.aspxhome.com/file/2023/2/110002_0s.png)
PHP bin2hex()函数基础实例讲解
![](https://img.aspxhome.com/file/2023/7/55397_0s.png)
python 获取文件列表(或是目录例表)
go doudou应用中使用注解示例详解
![](https://img.aspxhome.com/file/2023/3/105103_0s.png)