• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Parameters from Java to JavaScript

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I'm trying to pass parameters from java to java script.
I'm getting an error " JavaScript error :type 'javascript' into location for details " in the bottom of my screen of my browser(Netscape).
What about setting the class path???
Thanks all for your time.
Here is the codes:
import java.awt.*;
import java.applet.*;
import netscape.javascript.JSObject;
import java.lang.*;

public class array extends java.applet.Applet
{
public void init()
{
// Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
symantec.itools.lang.Context.setApplet(this);

// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setSize(426,266);


//}}
try
{
win= JSObject.getWindow(this);
}
catch(Exception e){}

}

//{{DECLARE_CONTROLS
//}}
String testStr;
Integer testInt;
Character testChar;
JSObject win;
Object testArray[]=new Object[3];
void create()
{

testStr=new String("Test string");
testInt=new Integer(1);
testChar=new Character('a');

testArray[0]=testStr;
testArray[1]=testInt;
testArray[2]=testChar;
try
{
win.call("extractArray",testArray);
}
catch(Exception e){}
}
public void paint(Graphics g)
{
g.drawString("here is an applet ",50,25);
}


}
//***********************************************************
Here is the HTML file
<HTML>
<HEAD>
<SCRIPT>
function extractArray(var1,var2,var3)
{
alert ("java return string: " + var1);
alert ("java return int : " + var2);
alert ("java return char : " + var3);
}
</SCRIPT>
</HEAD>
<BODY>
<center>
<HEAD>
<form>
<input type=button value=click onClick=document.array.create()>
</form>

<APPLET name = array code=JSObject.class MAYSCRIPT >

</APPLET>
</BODY>
</center>
</HTML>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic