Il te faut ce code :
	
	| 12
 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
 
 | public final void executeJS(String s)
	 {
	     String s1 = null;
	     boolean flag = false;
	     try
	     {
	         Method method = null;
	         Method method1 = null;
	         Object obj = null;
	         Class class1 = Class.forName("netscape.javascript.JSObject");
	         Method amethod[] = class1.getMethods();
	         for(int i = 0; i < amethod.length; i++)
	         {
	             if(amethod[i].getName().compareTo("getWindow") == 0)
	             {
	                 method = amethod[i];
	                 continue;
	             }
	             if(amethod[i].getName().compareTo("eval") == 0)
	                 method1 = amethod[i];
	         }
	         Object aobj[] = new Object[1];
	         aobj[0] = this;
	         obj = method.invoke(class1, aobj);
	         aobj[0] = s;
	         Object obj1 = method1.invoke(obj, aobj);
	         if(obj1 instanceof String)
	             s1 = (String)obj1;
	         else
	             s1 = obj1.toString();
	         flag = true;
	     }
	     catch(InvocationTargetException invocationtargetexception)
	     {
	         s1 = "" + invocationtargetexception.getTargetException();
	     }
	     catch(Exception exception)
	     {
	         s1 = "" + exception;
	     }
	     if(!flag)
	         System.out.println("eval failed with error " + s1 + " expression : " + s);
	 } | 
 Cette fonction prend l'appel javascript que tu souhaites dans le string en paramètre :
Par exemple :
	
	executeJS("alert('Appel qui viens de Java.')");
 Bon courage,
						
					
Partager