cancel
Showing results for 
Search instead for 
Did you mean: 

Closing a Application Window

Former Member
0 Kudos

Hi,

I have been searching this forum, but have not been able to locate an answer to this problem, close ones, but not ones that I have had work.

I want to close a window using a button. I have tried javascript and it has not worked, and many different ways. What I have done now is done an onClick event that goes to DO_HANDLE_EVENT and calls my method ON_CLOSE. Within the ON_CLOSE, I call navigation->exit( ), and place no exiturl inside the parenthesis. All this does is reload the page that I was on in the initial state.

Is there something that can be entered into the parenthesis to force the window to close? Or, is there another way of closing the window?

Best regards,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

What JavaScript have you tried? I always use something like the following JavaScript in my onClickClick:

window.close();

maximilian_schaufler
Active Contributor
0 Kudos

You have to be aware that when using JavaScript like this, you will run into the browser's security settings very quickly:

Usually a browser window will not let itself get closed by javascript unless it was called/opened by javascript.

To close a user-opened window using javascript the user will have to confirm the javascript action ... and having this additional pop-up appearing might not be what you want your user's to see (as they could and probably will start complaining about it) ...

Former Member
0 Kudos

Hi guys,

This is the code that I am using right now, the javascript way:

<script language="javascript"><!--

function windowClose() {

if(confirm('Do you want to close?')){

window.close();

}

}

//--></script>

and this is the call from the link:

<a class="urBtnStd"

href="#"

onClick="windowClose();"

style="white-space:nowrap;width:10%;">Close Window

</a>

This is all inside a <hrrcf:mainGroup> tag.

The confirm comes up and asks if I want to close the window, but when you click OK, the confirm popup disappears and the page stays the same.

There might be some problems with BSP tags and Javascript that I don't know about.

Best regards,

Kevin

athavanraja
Active Contributor
0 Kudos

Do you get any JavaScript error?

Can you tell us the error?

I just placed your code in a normal html page and it works fine. (it pops us with the message that"the web page you are viewing is trying to close the window.. do you want to close.." after i click ok in the confirm box.)

Regards

Raja

Former Member
0 Kudos

Hi Durairaj,

I was not getting any javascript error at all. I had tried putting the code in a normal HTML page as well and it worked for me, that's what baffled me. I wish I could tell if there was an error in the background. But what I can tell you is the answer.

I'm no javascript wizard, but I looked up to see what different methods .close() worked with, and I found one.

I used parent.close() and it works perfect. When I added the if (confirm... clase into the function, it went into it, but I couldn't understand why window.close() wouldn't work. I had tried self.close() as well, and it did nothing.

I guess the way that the MVC BSPs are built, they are nested in different frames of iframes and so parnet.close() is what was needed.

Thanks for all the help, it is really appreciated.

Best regards,

Kevin

athavanraja
Active Contributor
0 Kudos

Hi Kevin,

Good to hear that you could find a solution for your problem.

Regards

Raja

Former Member
0 Kudos

I am using a very similar process and have parent.close() which works fine. However the session still lives on the backend system...Looks like when I did parent.close() the browser did not have time to send the request to close the session to the backend system

maximilian_schaufler
Active Contributor
0 Kudos

When you close a window, there is no further request sent to the server - the client just exits, that's it, session on the server will remain active.

You would have to close that session manually by sending a special request before the client window is closed.

Former Member
0 Kudos

Hey guys,

I found this screen in the e-Recruiting 3.0 system that may help, but I don't know if the tag has session ending information in the background.

<%@extension name="hrrcf_bsp_ext" prefix="hrrcf" %>

<hrrcf:messageView title="Close Window" text="The window will close" windowClose="TRUE"/>

Unfortunately, there is no help on the tag library for hrrcf_bsp_ext.

Think this helps?

Kevin

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi guys.

This is the javaScript for closing the current window without the IE answer oranything:

function closeWindow()

{

var answer=confirm("Are you sure you want to log off ?");

if (answer == true)

{

var currWindow = window.top;

currWindow.opener = window.top;

currWindow.close();

}

}