We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › can the page that an applet is on send info to it
Page Index Toggle Pages: 1
can the page that an applet is on send info to it? (Read 601 times)
can the page that an applet is on send info to it?
Sep 3rd, 2009, 11:18am
 
is there a way to make a random value that is the same on an applet and the webpage it is on.

In flash this can be done using flashVars:
The webpage (php) makes the variable.
The variable is printed in the script that calls the applet.
The variable can then be displayed in the applet.


Re: can the page that an applet is on send info to it?
Reply #1 - Sep 3rd, 2009, 11:25am
 
Java (thus Processing) can communicate with JavaScript on the Web page hosting the applet. So you can get a value displayed in the page.

Not sure what you mean by "printed", but you can generate the <object> tag defining the applet, and you can include more <param name="x" value="y"> tags which can be read by the applet. Not need to JavaScript there.
Re: can the page that an applet is on send info to it?
Reply #2 - Sep 3rd, 2009, 12:07pm
 
thanks for the reply, but i still am a little confused.

lets just look at the simplest example i can think of.

code (processing) :
Code:

int x=<howToGet value from the page the applet is on??>;
line(x,1,1,50);


html (... means i skipped stuff)
Code:

...
<!--[if !IE]> -->
<object classid="java:get_data_from_page.class"
type="application/x-java-applet"
archive="get_data_from_page.jar"
width="100" height="100"
standby="Loading Processing software..." > 
   
<param name="x" value="100">    
...
<!--<![endif]-->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
width="100" height="100"
standby="Loading Processing software..."  >

<param name="x" value="100">
...
</object>
<!--[if !IE]> -->
</object>
<!--<![endif]-->


     i put the param x there twice, (ie and firefox). is that correct?

and the processing code will not export unless i give x a value, but i want the value to come from the java-script not from with in the applet.
Re: can the page that an applet is on send info to it?
Reply #3 - Sep 3rd, 2009, 1:02pm
 
See param()
Page Index Toggle Pages: 1