Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1147 How do I detect what size a window is and then resize an embedded java applet to fill the whole window?

You are here: irt.org | FAQ | JavaScript | Java | Q1147 [ previous next ]

Try this (v4 browsers only):

<html>
<body>

<script language="JavaScript"><!--
w = 640;
h = 480;
NS4Plus = (document.layers) ? 1 : 0;
IE4Plus = (document.all) ? 1 : 0;

if (NS4Plus) {
   w = window.innerWidth;
   h  = window.innerHeight;
}
if (IE4Plus) {
/* The script must be inside the body tags - there is no body in the head of the document */
   w = document.body.clientWidth;
   h = document.body.clientHeight;
}
// alert(w+'x'+h);

/* You might want to take 5% off the height and width to cater for scroll bars */

Text = '<applet width='+w+' height='+h;
Text += ' name="SomeApplet" code="somejava.class">';
Text += '\n<param...............>';
Text += '\n<\/applet>';
document.write(Text);
//--></script>

</body>
</html>

©2018 Martin Webb