Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing Parameters from Java to JavaScript

 
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>
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic