473,225 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

Setting applet window size using javascript?

I've always been bothered about having to statically declare the size of
a Java applet window (container?) in the calling HTML. I've always
wanted the moral equivalent of width=50% statement (of the window or
frame). I'm trying to use Javascript to do so.

I can sort of get an example working in a Mozilla browser:
<!-- This works on Mozilla only (and maybe netscape) -->
<script language="Javascript">
document.write( "<applet code=MyApplet.class width="
+ window.innerWidth/2 + " height=" + window.innerWidth/2 +

"></applet> <br>" ); </script>
So the document.write statement produces a normal looking applet string
like this:

<applet code=MyApplet.class width=252.5 height=252.5></applet>

Which gets intepreted by the browser, kicking off the Java applet. But
as you resize the browser the alignment with other text in the html
window is funky. Also, in the above example, the window.innerWidth is
apparently from the Mozilla/Netscape DOM, not MS-IE's.

Does anybody have any Javascript examples of how to dynamically presize
an applet to some percentage of the window/frame width? (that's mostly
portable)

--
Ben in DC
Pu***********@benslade.com (put 030516 anywhere in the subj to get thru)
"It's the mark of an educated mind to be moved by statistics"
Oscar Wilde

Jul 20 '05 #1
2 12755
VK
Inline applet (allocated on the web-page) doesn't support resize()
method: "once done, it's done".

You can catch resize events from JavaScript and reload the page with
applet over and over on each resize. Evidently the current state of
applet will be lost.

Put 030516 in email subj to get thru <Pu***********@benslade.com> wrote
in message news:R8***************@nwrddc02.gnilink.net...
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always
wanted the moral equivalent of width=50% statement (of the window or
frame). I'm trying to use Javascript to do so.

I can sort of get an example working in a Mozilla browser:
> <!-- This works on Mozilla only (and maybe netscape) -->
> <script language="Javascript">
> document.write( "<applet code=MyApplet.class width="
> + window.innerWidth/2 + " height=" + window.innerWidth/2 + "></applet> <br>" ); </script>
So the document.write statement produces a normal looking applet

string like this:

<applet code=MyApplet.class width=252.5 height=252.5></applet>

Which gets intepreted by the browser, kicking off the Java applet. But as you resize the browser the alignment with other text in the html
window is funky. Also, in the above example, the window.innerWidth is
apparently from the Mozilla/Netscape DOM, not MS-IE's.

Does anybody have any Javascript examples of how to dynamically presize an applet to some percentage of the window/frame width? (that's mostly
portable)

--
Ben in DC
Pu***********@benslade.com (put 030516 anywhere in the subj to get thru) "It's the mark of an educated mind to be moved by statistics"
Oscar Wilde

Jul 20 '05 #2
Actually, I wasn't asking to resize anytime, just *pre* size one time based on the
width of the web browser screen when the HTML page is loaded.

I think I came up with a solution. Here's my slightly verbosely
commented example, (also see www.benslade.com/DynAppletSize.html, note that I needed
the Sun Java plugin for this to work with MS-IE 6 on Win XP. Why?)

The first part which calculates the browser window dimensions has to come
after the <body> declaration for certain web browsers:
<body>

<script language="Javascript">
// Calc window/screen width/height for Mozilla, NN>4, IE>4, IE6 in CSS1Compat mode (with a Formal DOCTYPE)
// from http://jibbering.com/faq/ with slight mods
// Note, this size calc must be in the body for IE 5+
// Exports global variables winWidth, WinHeight

var d=document;
var winWidth, WinHeight;

if (typeof window.innerWidth!='undefined')
{ winWidth = window.innerWidth; var winHeight = window.innerHeight; }
else
if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0)
{ winWidth = d.documentElement.clientWidth; winHeight = d.documentElement.clientHeight; }
else
if (d.body && typeof d.body.clientWidth!='undefined')
{ winWidth = d.body.clientWidth; winHeight = d.body.clientHeight; }
else { winWidth=150; winHeight=150; }
</script>
then somewhere later in the same HTML document. This example sizes
the Java applet to 1/2 the width of the web browser window:
<script language="Javascript">
// Dynamically generate the HTML for an applet tag so that
// it can be initially sized based on the browser window size
// The round() func is needed for MS-IE on Mac & PC?

document.write(
"<applet code=MySwitchTest.class width=" +
Math.round(winWidth/2) +
" height=" + Math.round(winWidth/2) + "> </applet> <br>" );
document.write(
"applet code=MySwitchTest.class width=" +
Math.round(winWidth/2) +
" height=" + Math.round(winWidth/2) + " /applet <br>" );
</script>
VK wrote: Inline applet (allocated on the web-page) doesn't support resize()
method: "once done, it's done".

You can catch resize events from JavaScript and reload the page with
applet over and over on each resize. Evidently the current state of
applet will be lost.


--
Ben in DC
Pu***********@benslade.com (put 030516 anywhere in the subj to get thru)
"It's the mark of an educated mind to be moved by statistics" Oscar Wilde

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fuzzyman | last post by:
I'm having trouble implementing my GUI using Tkinter...... I've been working through the Tkinter tutorials from 'Programming Python' and am generally happy enough with the functionality and feel...
6
by: Giuseppe Chielli | last post by:
Hi! I'm new to this newsgroup. I have a problem: I need to get the window size via Javascript; I usually use window.innerWidth or document.body.clientWidth with IE and Firefox and it properly...
2
by: JSheble | last post by:
Is there a way to set the size of the console window in a console app?
4
by: gsuns82 | last post by:
hi friends,can any one give the coding for finding file size using java script???
6
by: bushi | last post by:
hi everyone! i have diplayed my hyperlinks in a iframe.when i redirect to next page.the next page also open in the same frame,but i want to open a new browser window,when i click on the...
7
by: John Fox | last post by:
Dear All, How do I set the size of the window that is showing the database forms? can't find any helps on it. John Fox
2
by: spiralof5 | last post by:
Hi. I must first say I'm not an experienced scripter. Here's my problem and how far I am so far. I struggled for awhile to get the browser to fill most of it with my flash movie and keep it...
3
by: Annette Block | last post by:
I'm rather new in JavaScript, but I have some experience in php. I learned it's rather easy to open a window of a specified size with JavaScript, that you need to specify the opened file, but I...
3
Frinavale
by: Frinavale | last post by:
Hi there! I'm hoping that someone knows how to check the size of a file before it is uploaded to the server using JavaScript. I have seen suggested solutions using an ActiveX control to check...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.