J'ai une applet Java qui est incorporée dans html en utilisant la méthode object-comment-embed
. Je voudrais redimensionner l'applet chaque fois que la fenêtre du navigateur est redimensionnée. J'ai trouvé des solutions autour d'Internet, mais ils fonctionnent tous sur la base de la balise applet
obsolète.Comment redimensionner une applet Java lorsque le navigateur est redimensionné?
De même, en essayant un setSize()
appel sur mon élément embed
dans FireBug, il va redimensionner le contenu de l'applet, mais pas la fenêtre de l'applet. Autrement dit, la zone de l'affichage qui est donnée à Java ne change pas.
code actuel ressemble à ceci:
<object
id='MyApplet1'
width='300' height='200'
classid='clsid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
codebase='http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab#Version=1,6,0,0'>
<param name='type' value='application/x-java-applet;version=1.6'>
<param name='scriptable' value='false'>
<param name='codebase' value='foo'>
<param name='code' value='bar'>
<param name='archive' value='baz'>
<param name='arg1' value='A'>
<param name='arg2' value='B'>
<comment>
<embed
id='MyApplet2'
width='300' height='200'
pluginspage='http://java.sun.com/products/plugin/index.html#download'
type='application/x-java-applet;version=1.6'
scriptable='false'
codebase='foo'
code='bar'
archive='baz'
arg1='A'
arg2='B'>
<noembed>
</noembed>
</embed>
</comment>
</object>
<script type="text/javascript">
function resize() {
min_width = 300;
min_height = 200;
frame_width = 0;
frame_height = 0;
if(parseInt(navigator.appVersion) > 3) {
if(navigator.appName=='Netscape') {
frame_width = window.innerWidth;
frame_height = window.innerHeight;
}
if (navigator.appName.indexOf('Microsoft') != -1) {
frame_width = document.body.offsetWidth;
frame_height = document.body.offsetHeight;
}
}
frame_width *= 0.78;
frame_height *= 0.78;
applet_width = frame_width > min_width ? frame_width : min_width;
applet_height = frame_height > min_height ? frame_height : min_height;
document.getElementById('MyApplet1').setSize(applet_width, applet_height);
document.getElementById('MyApplet2').setSize(applet_width, applet_height);
}
window.onResize = resize;
window.onLoad = resize;
</script>
Votre fonction de redimensionnement appelée? (Par exemple, où est l'erreur jusqu'à présent?) – scunliffe