window.location.href=""

来源:互联网 发布:管理鞋子软件 编辑:程序博客网 时间:2024/05/20 05:56

人总要为自己的错误买单
当使用window.location.href=”“传参数的时候,比如定义一个

var str;        window.location.href="*Controller.do?*&参数=str";

这样传递参数是错误的,只会把str识别成字符串。正确的应该是

window.location.href="*Controller.do?*&参数="+str+"";

上述错误也解释了为什么有的时候window.location.href会造成执行两次的错觉。代码规范真的很重要。

0 0
原创粉丝点击