FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Passing Parameters from the Web Page
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Passing Parameters from the Web Page  (Read 2541 times)
anhinga

WWW Email
Passing Parameters from the Web Page
« on: Aug 10th, 2003, 6:44am »

Is it possible to pass parameters from the web page to proce55ing?  I would like to imbed the same procesing app in a few diffrent web pages, but change some colors.  i suppose i could recompile a different version of the same app for each page, but i would like to keep the download time of the site to a minimum.
 
thanks,
jason
 
toxi

WWW
Re: Passing Parameters from the Web Page
« Reply #1 on: Aug 11th, 2003, 3:05pm »

AFAIK there's no direct Processing way to get parameters, but you can use the plain java syntax:
 
Code:
void setup() {
  try {
    int bg = Integer.parseInt(getParameter("bg"),16);
    int r = bg >> 16 & 0xff;
    int g = bg >> 8  & 0xff;
    int b = bg  & 0xff;
    background(r,g,b);
  }
  catch (Exception e) {
    background(0); // default colour
  }
}

 
then add this tag below to the <applet> tag in your html document:
 
<param name="bg" value="ffcc00">
« Last Edit: Aug 11th, 2003, 3:09pm by toxi »  

http://toxi.co.uk/
anhinga

WWW Email
Re: Passing Parameters from the Web Page
« Reply #2 on: Aug 14th, 2003, 8:58am »

Thank you very much.  Your code works wonderfully.
 
jason
 
pollux

WWW Email
Re: Passing Parameters from the Web Page
« Reply #3 on: Sep 3rd, 2003, 10:16pm »

thanks toxi, this gave me an idea for checking if an applet is online or in authoring mode...
 
http://proce55ing.net/discourse/yabb/board_Tools_action_display__num_1062620102.html
 

pollux | www.frwrd.net
toxi

WWW
Re: Passing Parameters from the Web Page
« Reply #4 on: Feb 14th, 2004, 1:53am »

just wanted to note that the above solution is obsolete now as you can use the param() function. reference is here:
 
http://processing.org/reference/param_.html
 

http://toxi.co.uk/
Mythmon


Re: Passing Parameters from the Web Page
« Reply #5 on: Feb 20th, 2004, 4:56am »

is there any way to use the
http://www.mysite.com/mypage.html&?var=12
form of passing parameters to applets? i know it possible in flash, i think
 
Bijeoma

myloveiloved
Re: Passing Parameters from the Web Page
« Reply #6 on: Feb 20th, 2004, 7:50am »

if you know a server side lanuage you can write the html document. and use the var as a variable for a parameter in the applet tag.
 
Pages: 1 

« Previous topic | Next topic »