View Full Version : Loading Java Applet

03-30-2009, 01:43 PM
I have a few pages that load a java viewer for my end users to view tiff images.

I have the viewer in an IFRAME.

Everything seems to be displaying ok in IE (windows), Mac (Safari and Firefox)

What does not seem to work is in Windows Firefox.

I am wondering I should just set the height and width to pixels because I know the size of my IFRAME I am using in the browser.

Do you see anything wrong wtih the way this is working (the vendor provided this as an example)

Iframe Code

<div style="width:850px; height:725px;">
<iframe width="98%" height="725px" scrolling="no" src="viewer.asp"></iframe>

JS Function

<SCRIPT LANGUAGE="javascript">
var _info = navigator.userAgent;
var needWindowSize = false;

defaultStatus="Loading Viewer...";

// Netscape 6 and beyond on Mac do not interpret percent sizes so we set flag to get
// applet size from window size
if (_info.indexOf("Mac") > 0 && navigator.appName.indexOf("Netscape") >= 0 && navigator.appVersion >= "5") {
needWindowSize = true;

// IE on Mac and Netscape 6 on Mac does not resize properly, so we must reload the window
if ( _info.indexOf("Mac") > 0 && (_info.indexOf("MSIE") >= 0 ||
(navigator.appVersion >= "5" && navigator.appName.indexOf("Netscape") >= 0) ) ) {

// reload window on resize (for IE on Mac and Netscape 6 on Mac)
function resizeFunc() {
location = location.href;

// Called after applet is done loading.
// Set status so that is doesn't change all the time as user moves cursor in
// and out of applet
function Loaded() {
defaultStatus="Viewer running";
return true;

Here is the code to load the viewer....

<SCRIPT LANGUAGE="javascript">
document.write("<applet codebase='javabin' code='test.class' archive='test.jar' id=viewer name='viewer' hspace=0 vspace=0 ");
document.write("ALT='Java capability is required to view images. Check the browsers options to make sure that Java is enabled' ");
if (needWindowSize) {
document.write("width="+(innerWidth) +" height=" + (innerHeight) + ">");
} else
document.write("width=100% height=100%>");

03-30-2009, 02:10 PM
The height of the applet seems to be what is left to display on the screen from where the IFRAME starts.