今天在做项目的过程中,碰到如下一个问题:
<html>
<head>
<title>Test</title>
<script>
function click(url){
//alert(url);
location.href=url;
}
</script>
</head>
<body>
<a href="javascript:click('http://localhost:8080/configurator/dojo/apps/br/solution-configurator-v015.jsp?lang=en&p=r%26w
');">test</a>
</body>
</html>
注意红色的参数p=r%26w 其真实的形式应该是: p=r&w, 我想让p=r%26w 在随后的地址栏中原样的显示出来、、、
也就是:
http://localhost:8080/configurator/dojo/apps/br/solution-configurator-v015.jsp?lang=en&p=r%26w
但是经过实践之后,还是被转换成了p=r&w:
http://localhost:8080/configurator/dojo/apps/br/solution-configurator-v015.jsp?lang=en&p=r&26w
如果我写成下面的形式:
<html>
<head>
<title>Test</title>
<script>
function click(){
//alert(url);
location.href="http://localhost:8080/configurator/dojo/apps/br/solution-configurator-v015.jsp?lang=en&p=r%26w";
}
</script>
</head>
<body>
<a href="javascript:click();">test</a>
</body>
</html>
这个时候就是满足我要求的、、、
但是由于在实际情况下,这个链接是动态生成的,没有办法在js里面写死、、、
继续找寻方法中、、、