Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access applet variable from HTML page

Status
Not open for further replies.

Rodie

Programmer
Jun 27, 2004
132
FR
Hi [glasses]

I created a java applet that is loaded in a HTML page containing Javascript (to interact with the applet).

I would like to initialize the variables of my applet and use the <PARAM> tag to customize the applet variables from the side of the HTML page.

For example : on the java class
Code:
public class Test extends Applet {
public int var;
}

in HTML page :
Code:
<APPLET name="Test" width="1" height="1" code="Test.class" codebase="." mayscript="mayscript">
<PARAM name="var" value="js_var">
</APPLET>
<SCRIPT LANGUAGE="javascript">
document.Test.js_var = 3;
</SCRIPT>

But this does not work .. thanks if you know how to do
 
This link explains how to pass parameters to your applet :
What you are trying to do will fail for two reasons :

1) The javascript block is executed after the applet tag.
2) "js_var" is a value - not a tag name or id. If it were to work, it would be like accessing a form I guess - eg : "document.Test.var.value = 3" - but this does not work either. Not sure how you would get it to work. Probably easier to do with server-side scripting.

--------------------------------------------------
Free Database Connection Pooling Software
 
You are right : js_var is a value!
I finally do something like this :

Code:
public class Test extends Applet {
public int var = getParameter("js_var");
}
Code:
<APPLET ...>
<PARAM name="var" value="49.56.21.255">
</APPLET>

Thanks to you !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top