Bonjour à tous,
Cela fait quelques jours que je tourne en rond pour trouver comment récupérer une valeur qui se trouve dans mon applet grâce au javascript.
Je sais qu'il faut que j'utilise getElementById("mon applet").value mais celui-ci me rend undefined comme valeur!
Merci pour votre aide.
Voici mon code html
Et voici le code de mon applet
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <HTML> <HEAD> </HEAD> <BODY> <div style="height:500px; width:700px; overflow : auto;"> <xsl:variable name="zoom_init"><xsl:value-of select="//zoom"/></xsl:variable> <xsl:variable name="largeur"><xsl:value-of select="700*$zoom_init"/></xsl:variable> <xsl:variable name="hauteur"><xsl:value-of select="500*$zoom_init"/></xsl:variable> <img id="imgId" src="C:\Documents and Settings\scourboin\My Documents\My Pictures\image.jpg" height="{$hauteur}" width="{$largeur}" onclick="alert(document.getElementById('app').value);"/></div> <APPLET codebase="C:\Documents and Settings\scourboin\My Documents\scroll" code="scrollbar.class" WIDTH="200" HEIGHT="40" NAME="app" MAYSCRIPT="mayscript"> </APPLET> </BODY> </HTML>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 import java.applet.*; import java.awt.*; public class scrollbar extends Applet { int v2=10; //valeurs initiales Font font = new Font("Helvetica",0,12); Panel panN = new Panel(); BorderLayout bl= new BorderLayout(0,0); Scrollbar sc2=new Scrollbar(0,v2,1,0,43); public void init( ) { setBackground(Color.white); setFont(font); setLayout(bl); add("North",panN); panN.setLayout(new FlowLayout(0,0,0)); panN.setLayout(new BorderLayout(5,0)); panN.add("South",sc2); } public boolean handleEvent(Event evt) { if (evt.target==sc2) { v2=sc2.getValue(); } else return super.handleEvent(evt); repaint(); return true;} public void paint(Graphics g) { g.drawString("A1 = "+v2,0,30); } }
Partager