JS来获取页面的URL:
(1)普通的格式是:window.location.href
(2)但是如果是登录时候先弹出个对话框,这个对话框里面是登录的页面login.jsp,这个时候在这个对话框里面如果想获取最外层的url的方式,就必须用 top.location.href 了。
例子如下:
var strHref = top.document.location.href;
var intPos = strHref.indexOf("#");
var strRight = strHref.substr(0,intPos);
if(num == "success"){
top.location.href = strRight;
}else if(num !== "null"){
document.getElementById("error_login").innerHTML = num;
}
另外还有一种情况是:
在form提交表单的时候有个属性可能对上面的(2)的情况有用target="_top"
<form name="loginForm" action="Login.action" method="post" target="_top">
</form>