Bonjour à tous,
J'ai un problème j'ai réalisé un applet et je veux appeler une fonction de l'applet dans ma page html grâce à du javascript mais je n'ai aucun résultat voici mon code
fonction de l'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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
public class Browse extends JApplet {
 
 
	//initialisation de l'applet
	public void init() {
	    try {
	        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
	            public void run() {
	            	createGUI();	                
	            }
	        });
	    } catch (Exception e) {
	        System.err.println("createGUI error");
	    }
	}
 
	private void createGUI() {
 
		// contenu de l'applet
		//String[] tab=roots();
		try {
			upFile("/poisson.jpg","http://localhost:8080/upload_test/page4.jsp");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
 
	public String petitEssai(){
		String s = "ca marche l'applet";
		return s;
	}
 
	public String tabVersString(){
		String s="";
		String monTab[]=folder("/");
 
		for (int i = 0 ; i < monTab.length ; i++) {
		     s=s + monTab[i] + ";";		      
		    }
 
		return s;
	}
 
	//fonction qui renvoie les noms des disques dans un tableau de String
	public String[] roots(){
		File[] drive;
		drive = File.listRoots();
 
		String monTableau[]=new String[drive.length];
 
	    for (int i = 0 ; i < drive.length ; i++) {
	      monTableau[i]=drive[i].toString();
 
	    }
 
		return monTableau;
	}
}
et la page 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
39
40
41
42
43
44
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.36">
  <style type="text/css">
  </style>
  <script type="text/javascript">
			function affichRacine(){
				var str = document.applet.petitEssai();
				document.writeln(str); // la fonction petitEssai fonctionne
				var s = document.applet.tabVersString();//celle la non
 
 
			}			
 
</script>
</head>
<BODY>
 
 
 
<applet id="applet" name="applet" code="applet.Browse" codebase="." 
archive="MonApplet.jar,lib/httpclient-4.1.1.jar,lib/httpmime-4.1.1.jar,lib/httpcore-4.1.jar,lib/httpclient-cache-4.1.1.jar"  
width="300" MAYSCRIPT height="300">
</applet>
 
 
 
 
<a href="javascript:;"
onClick="affichRacine();">
Cliquez ici!</a>
 
</BODY>
 
 
 
</body>
</html>
merci parce que je ne comprend pas peut être que la fonction n'est pas compatible avec du javascript enfin je sais pas