Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Closing and opening jsp pages in javascript?

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.

4 Answers

Relevance
  • 1 decade ago
    Favourite answer

    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","");

  • Anonymous
    1 decade ago

    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.

  • 4 years ago

    Jsp Close Window

  • ?
    Lv 4
    5 years ago

    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.

Still have questions? Get answers by asking now.