June 05, 2008

Forms Shutdown

In the article forms-startup I wrote last year how to hide the browser-window, while starting a forms-application. Another problem is: How can we close the browser-window after exiting the forms-application. Here is my favorite solution:

1) Create a new html-file e.g. close.html in your html-directory. This is the main routine, which closes the browser-window.


< BODY onLoad="window.close();" >

2) Set the formsweb.cfg parameter HTMLbeforeForm in the server-directory. This eliminates the security-question "Do you want to close the browser-window".

HTMLbeforeForm=< SCRIPT LANGUAGE="JavaScript" >window.opener = top;< /SCRIPT >

3) The form, which closes the main-application needs a POST-FORM-trigger. /forms/html is a virtual-directory, which points to the close.html.

web.show_document ('/forms/html/close.html', '_self');

Used directories:

< DevSuite-Home > : Your Developer-Suite Home Directory
html-directory : < DevSuite-Home >\tools\web\html
server-directory : < DevSuite-Home >\forms\server
virtual-html-directory : /forms/html defined in forms.conf

Many thanks to Duncan Mills, Frank Nimphius and Richard Squires, who posted this code in the OTN years ago.

Pro) This technique works on IE 6 and IE 7, tested with JInitiator and Sun-Plugin.
Contra) No Firefox-Support. Since Firefox 2.0 it isn't allowed to close a window via JavaScript.

Important: The limitations of this blog forced me to write blanks after each "<" and before each ">". Don't write them, when you use this technique !

have fun
Gerd

9 comments:

Mark said...

Gerd,

I used the following code in the web.show_document
('javascript:window.open("","_parent","");window.close();','_self'); this way I did not have to make a seperate close.html file which also has to be deployed to the application server.

Regards,

Mark

Gerd Volberg said...

I tested it in many ways. Your tip isn't running. Who has an idea, what the problem is?

Mark said...

I will also go back to the drawing board and test it again. I used it before in combination with internet explorer 6. I'm now testing with ie7 and firefox3 but it does not seem to work either.

Anonymous said...

We are using this method, but occasionally IE hangs and we have to close IE from the task manager. When this happens and before we end the task, we look at the app server and the forms session has ended. We have been unable to determine what is causing this intermittent problem. Any suggestions as to where to look would be greatly appreciated. Our clients are windows XP, IE 6, jinit 1.3.1.28. Our AS servers are win2003, AS 10.1.2.0.2 Forms and Reports. Our close.html contains the following code with < replaced by *:
*html>
*body onload="closeit()">
*script>
function closeit()
{
win = top;
win.opener = top;
win.close ();
}
*/script>
*/body>
*/html>

tia

Gerd Volberg said...

Hi Cheryl,
did you test all three parts of my posting?

Anonymous said...

I have tested all your given step. When Post-Form trigger fire it gives a message "Do you want to close this file?".How can I eliminate this message.

I also followed this step
2) Set the formsweb.cfg parameter HTMLbeforeForm in the server-directory. This eliminates the security-question "Do you want to close the browser-window".

But still the message came.

Please guide.

Gerd Volberg said...

is that a message from the POST-FORM or from your browser?

Fola said...

Gerd thanks for your good work on this blog, I have always read you comments and it has inspired me to attain the professional level in Oracle 10g but please may I ask... what does it take to become an oracle certified trainer? Pls I need your comment(s) and you may send me a mail via morounodebode@gmail.com
Thanks in anticipation.

Gerd Volberg said...

To become Oracle Certified Trainer: in my case very easy, because OPITZ CONSULTING is one of the 16 Oracle University Centres in germany. Then you ask ORACLE to become trainer.

After that you have to (1.) hear the cource, then (2.) hold the course with an Oracle trainer in Oracle rooms. There you get your certificate and then you can (3.) hold trainings for the Oracle University