Javascript函数: escape()

JavaScript escape() 函数返回经过重新编码过的字符串。

escape()格式

escape(String)

escape()参数

String 必填。String 对象或文字。

注意:

escape()只编译符号和中文,英文则原样输出。要查看escape()编译过的内容要使用unescape()方法

测试代码:

<script type=”text/javascript”>
document.write(”测试字符串<font color=”#FF0000”>Javascript escape函数</font> 编码后<font color=”#FF0000”>”);
document.write(escape(”Javascript escape函数”));
document.write(”</font><br>”);
</script>

运行结果:
测试字符串Javascript escape函数 编码后Javascript%20escape%u51FD%u6570

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据