Returning an object from Java to JS
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vinod_Kaggal
Posted On:   Tuesday, February 26, 2002 08:56 PM

Test JS to AppletCommunication function func1() { var serialArr; alert("in the function"); if(navigator.appName == "Netscape") { serialArr = document.applets[0].getSerials(); alert("element 1 :" + serialArr[0]); } else { serialArr = document.applets[0].getSerials(); alert("Applet Name :" + document.applets[0].name); alert("element length :" + serialArr.length); alert("serialArr :" + serialArr); } } ]]>]]> I have writen a simple applet that returns a String array to JavaScript. But, I am unable to get it to work in IE5 or IE6. Can anybody help me please? Here is the applet code:    More>>
Test JS to AppletCommunication

I have writen a simple applet that returns a String array to JavaScript.
But, I am unable to get it to work in IE5 or IE6.

Can anybody help me please?

			
				
Here is the applet code:



import java.applet.*;
import java.awt.*;
import netscape.javascript.*;
public class JStoApplet extends Applet
{
static int num = 10;
String s;

public String[] getSerials()
{
String[] news = {"012345", "546789", "345627"};
//win.alert("news :" + news);
return news;
}

public Object getApplet()
{
return this;
}

/**
* JStoApplet constructor comment.
*/
public JStoApplet()
{
super();
}
public JSObject win;
public JSObject doc;
public JSObject loc;

public void init()
{
try
{
//get the object "Window"
win = JSObject.getWindow(this);
doc = (JSObject) win.getMember("document");
loc = (JSObject) doc.getMember("location");

s = (String) loc.getMember("href"); // document.location.href

javax.swing.JPanel panel = new javax.swing.JPanel();
panel.setLayout(new FlowLayout());

panel.add(new javax.swing.JLabel(s));

//add the panel to the applet area
add(panel);

}
catch(Exception e)
{}



}

}


here is the html that invokes/contains the applet












Here is the applet. It should display the location of this document.









Serial from ...







Any help will be appreciated




Thanks in advance.    <<Less
About | Sitemap | Contact