I have a page index.jsp available at this link https://www.dropbox.com/s/0smy7nlcmilkqt4/index.jsp.
This file contains a JavaScript method named validateloginForm() and is used to validate input fields.
If the fields are filled then it will redirect to another JSP page, but when I remove the alert("after"); line below the window.open() line, then it does not redirect to another page.
Please let me know why I need to have this alert("after") after calling window.open().
function validateloginForm()
{
var empId = document.getElementById("empId").value;
var empPass = document.getElementById("empPass").value;
if( empId == "" )
{
alert("Enter id !");
}
else if( empPass == "" )
{
alert("Enter password !");
}
else
{ window.open("validateUser.jsp?"+"empId="+empId+"&empPass="+empPass,"_parent","","");
alert("after");
}
}
Because the code after
window.openis executed immediately and the window isn’t loaded at that point.Using
.alertis only a coincidence, if you dismissed the alert before the window was loaded, it still wouldn’t work.