Java+JavaScript
Anyone know if it is possible to use the DOM in javascript to change the size of a Java Applet dynamically? I've tried giving a name to the applet inside of the tag like:
<applet name="SomeApplet" height=0 width=0></applet>
And then trying to change it in javascript such as:
document.layers["SomeApplet"].height = 100;
document.layers["SomeApplet"].width = 100;
But it returns an error saying document.layers.SomeApplet is null or not an object.
So anyone know if there is a way to do this? Why would I want to do this? Well basically, change the size of an applet without reloading the page or the applet itself.
I suspect APPLET objects lie outside the DOM.
Might I suggest you take a look at Java WebStart instead? You still distribute your application via a website, but it opens in a new top-level window instead. You can resize the window as much as you like then, and the user can even close the browser and leave your application running.
WebStart HOW-TO:
http://wiki.java.net/bin/view/Games/HowToUseWebstart
Examples:
http://grexengine.com/sections/externalgames/tech-page-Webstart.html
--cfmdobbie
Might I suggest you take a look at Java WebStart instead? You still distribute your application via a website, but it opens in a new top-level window instead. You can resize the window as much as you like then, and the user can even close the browser and leave your application running.
WebStart HOW-TO:
http://wiki.java.net/bin/view/Games/HowToUseWebstart
Examples:
http://grexengine.com/sections/externalgames/tech-page-Webstart.html
--cfmdobbie
Forget document.layers, that sounds like something out of Netscape4 DOM.
You MIGHT be able to do it using the proper dom functions, by manipulating the style of the applet (or object) element (Hint: use document.getElementById and then manipulate the style.width and height properties)
But don't hold your breath; Java applets aren't designed to be resized, so it might not work. Or it might just move around other elements on the page while leaving the applet the same size.
The same probably goes for Flash.
Mark
You MIGHT be able to do it using the proper dom functions, by manipulating the style of the applet (or object) element (Hint: use document.getElementById and then manipulate the style.width and height properties)
But don't hold your breath; Java applets aren't designed to be resized, so it might not work. Or it might just move around other elements on the page while leaving the applet the same size.
The same probably goes for Flash.
Mark
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement