-
JavaScript使用encodeURI()和decodeURI()获取字符串值,不能就是地址栏显示的字串,以前经常在网上见到有人问此问题,无意在网上发现,不知是不是您想要的,先看看效果吧。
-
<html>
-
<head>
-
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />
-
<title>石家庄花卉</title>
-
<script language=\"JavaScript\">
-
<!--
-
function showMsg()
-
{
-
var strURL= url.value;
-
var encodeStr = encodeURI(strURL);
-
var temp = encodeStr+\"\\n\";
-
temp += decodeURI(encodeStr);
-
alert(temp);
-
}
-
-->
-
</script>
-
</head>
-
<body>
-
<div>
-
请输入一个URL:<input name=\"url\" type=\"text\" id=\"url\" value=\"/search.php?keyword=Ajax\" size=\"60\" />
-
<input type=\"submit\" name=\"button\" id=\"button\" value=\"我要提交\" onclick=\"showMsg();\" /></div>
-
<dIV class=\"vc\" style=\"margin: 20px auto\" >
-
<h2>使用encodeURI()和decodeURI()函数:</h2>
-
</dIV>
-
</body>
-
</html>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29737856/viewspace-1253739/
,如需转载,请注明出处,否则将追究法律责任。