English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have 2 web pages adminIndex.jsp and regTypeQuery.html. I have a button on adminIndex.jsp. When I click the button on adminIndex.jsp I want the following to happen.

1> The window containing adminIndex.jsp must close and simultaneously the page regTypeQuery.html must open.

For this purpose I have tried the following 2 javascript functions and their variants.


function popupload1(form1)
{
mywindow=window.open("./regTypeQuery.html","mywindow","width=200,height=170");
mywindow.moveTo(200,300);
window.close("./adminIndex.jsp");

return true;
}

function popupload1()
{clw=window.self;
mywindow=window.open("./regTypeQuery.html","mywindow","width=200,height=170");
mywindow.moveTo(200,300);
clw.close()
}

Problem is regTypeQuery.html opens fine. But adminIndex.jsp doesn't close. Can any javascript expert suggest me the correct code? Don't say me that javascript can't close JSP pages.
At another place of the application I have opened JSP pages with javascript. So closing must be possible.

2007-01-14 03:25:44 · 4 answers · asked by binaryFusion 5 in Computers & Internet Software

4 answers

Try close();

Update: If you're going to thumbs-down the right answer, you're not a very good programmer.

Which browser are you using? window.close() works fine in IE, but it only works in Gecko (for Firefox versions 2+) if the Window was created by script. If you really, really want to do it, you'll have to create a Java applet to do it.

For Firefox 1.5, the following script line may work:
window.open("javascript:window.close();","_self","");

2007-01-14 03:38:26 · answer #1 · answered by achue500 3 · 0 1

First, a web programmer has to ask, why are you closing one window just to open another? Switching windows just for fun? There has got to be another way to accomplish what you're trying to make the browser do.

But I suppose you could get a reference to the window that opened you (look up 'opener' in dhtml references), and attempt to close it. If the 'opener' was a browser window that the user started up, it will complain somehow when being closed by a script. It'll say something like, 'A script is attempting to close this window, is this OK?'. There's no way to get around this over the web.

And if you have to do this in any browser than Internet Explorer, well, that's going to be extremely tough, if not impossible.

2007-01-14 03:51:39 · answer #2 · answered by Anonymous · 0 1

Jsp Close Window

2017-02-20 22:11:12 · answer #3 · answered by ayachi 3 · 0 0

i'm by no skill a Jscript guru. notwithstanding if, the final time i attempted to close a window, the IE protection stuff kicked in, prompting purchasers with the nasty "An app is attempting to close this window" message.

2016-10-07 03:35:46 · answer #4 · answered by ? 4 · 0 0

fedest.com, questions and answers