Tuesday, 29 July 2008

Oracle Forms: Web.Show_Document without Toolbars

When using web deployed Oracle Forms, it was really annoying that we just wanted to display a report or popup page in the broswer without the toolbars and buttons. They weren't necessary and they cluttered up the page. The web.show_document command didn't have an option to remove them so we came up with a little routine to get around the problem and make things a little nicer.

First we added a hidden iframe, to the page forms was running on and gave it the name "hiddenframe".

<iframe name="hiddenframe" style="display:none"></iframe>

We then created a new html page, "newWindow.html".

<html>
  <body>
    <h1>Open Page in a New Window</h1>
    <script type="text/javascript">
      var thisUrl = document.location.toString();
      var newPage = thisUrl.substring(thisUrl.indexOf("?",0)+1);
      var openWin = window.open(newPage,"_blank","resizable=yes,scrollbars=yes");
      openWin.focus();
    </script>
  </body>
</html>

This page is always called into "hiddenframe" with the report page we want to display passed as a parameter. Javascript in the "newWindow.html" page then opens a new window without toolbars and buttons and calls the desired page.

So if I wanted to open a page called myReport.html in a new window without toolbars and buttons I can call web.show_document as:

WEB.SHOW_DOCUMENT('http://myserver/newWindow.html?http://myserver/pls/myReport.html', 'hiddenframe');

The user needs popup blockers turned off for this server but this shouldn't be an issue for business applications of this type.

This is not restricted to Oracle Forms, it's so simple it can be used for any web application.
You can use this test page to test the newWindow.html page. Enter the url to open in the input box.

<html>
  <body>
    <h1>New Window Test</h1>
    URL: <input id="page" type="text" value="http://www.google.com/"/>
    <input type="button" value="Open" onclick="window.open('newWindow.html?'+document.getElementById('page').value,'hiddenframe')"/>
    <iframe name="hiddenframe" style="display:none"></iframe>
  </body>
</html>

Done...

1 comment:

Mathew said...

but how to close that parent window after open the new window