I know the title sounds a bit weird but so my problem is. I am developing a dynamic web project with eclipse/jsp. I am simply trying to bring a pop-up window by calling a javascript function and prevent redirect with a "return false". I will use servlet with ajax so I need to stop the execution with return false. The problem is javascript methods sometimes work, sometimes the method is not called at all. And sometimes the pop-up comes up yet return false does not effect and page is directed to "test.jsp?filePath=" I am keeping the javascript in a separate file called basic.js.
The JSP :
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="javascript/basic.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form id="showFilePath">
<input name="filePath" type="text">
<input type="submit" onclick="shouldWork()">
</form>
<p id="output">
</body>
</html>
and the javascript method is simply :
function shouldWork() {
alert("hello!");
return false;
}
many thanks in advance