1
我试图在JavaScript中重新加载之前传递一个变量。 如果我用下面的代码,在location.reload之前传递一个变量()
var myUrl = location.href;
if (myUrl.substring(myUrl.length-1) == "#")
{
myUrl = myUrl.substring(0, myUrl.length-1);
}
myUrl =myUrl+"&abc=Y&bdc=N";
location.href =myUrl;
location.reload();
这一次,我没有得到正确的url.ie,我不是在URL获得&abc=Y&bdc=N
。如果我把警报这样,
var myUrl = location.href;
if (myUrl.substring(myUrl.length-1) == "#")
{
myUrl = myUrl.substring(0, myUrl.length-1);
}
myUrl =myUrl+"&abc=Y&bdc=N";
location.href =myUrl;
alert(location.href);
location.reload();