closing jsp window
i have a jsp page that checks a query if the answer is true the program go开发者_JS百科es to a servlet page otherwise the program continue as planned my question is: if i do go to the servlet page how can i close the original jsp page from the servlet
It's true that you can close a window using JavaScript's window.close()
, but the window will only be closed when the window is opened by your application using window.open()
and not when it is opened by the enduser itself (e.g. by a link, form submit, bookmark, etc).
you can do it using javascript, and make them execute when your condition satisfy
You can not close browser window from the servlet.
But you can close window using javascript.
For example write something like:
<body onLoad="closeWindow(<% bean.isCloseWindow %>)">
And in javascript function "closeWindow" do something like this:
function closeWindow(ifClose) {
if (ifClose) {
window.close();
}
}
精彩评论