the encodeURIComponent function will do what you want.

<script type="text/javascript">
document.write("<iframe src='http://www.facebook.com/plugins/like.php?href=" + encodeURIComponent( document.location.href ) + "&layout=standard&show_faces=false&action=like&font=verdana&colorscheme=light' frameborder=0></iframe>");
</script>

encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。
encodeURI() 函数可把字符串作为 URI 进行编码。

对以下在 URI 中具有特殊含义的 ASCII 标点符号,encodeURI() 函数是不会进行转义的: , / ? : @ & = + $ # (可以使用 encodeURIComponent() 方法分别对特殊含义的 ASCII 标点符号进行编码。).

本文链接地址:https://const.net.cn/196.html

标签: none

添加新评论