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 & HelpIntegration › Close and or refresh Browser Window
Page Index Toggle Pages: 1
Close and or refresh Browser Window (Read 2609 times)
Close and or refresh Browser Window
Mar 7th, 2009, 5:19pm
 
Hi.. I need to know how to do 2 things:

In my processing script, I trigger the opening of a browser window using a sensor using the following command:

link ("http://www.somesite.com/php/openthispage.php");

the next time I trigger the sensor, it spawns the opening of another browser window.

How can I direct the process to look if the browser window exists, and if so, just resubmit/refresh it?

Similarly, how can direct the closing of a browser window that was opened?
     
Re: Close and or refresh Browser Window
Reply #1 - Mar 7th, 2009, 8:50pm
 
I don't think you can do what you want, unless, perhaps, you target a precise browser on a given system. Doing that in a portable way is much trickier: it depends on default browser of the user, you have to know which window you opened (to avoid closing a different one of the same browser), etc.
Re: Close and or refresh Browser Window
Reply #2 - Mar 8th, 2009, 2:52am
 
Well, from what I can see, the link command doesn't allow me to assign a window handle.

Should I/can I use a java method to open / close windows?

Does anyone have an example?
Re: Close and or refresh Browser Window
Reply #3 - Mar 9th, 2009, 2:32pm
 
Hi... I still can't solve this problem...

Anybody out there able to help?

I would really appreciate it...
Re: Close and or refresh Browser Window
Reply #4 - Mar 9th, 2009, 3:53pm
 
Again: PhiLho  wrote on Mar 7th, 2009, 8:50pm:
I don't think you can do what you want.
I mean that for closing a window opened by the link command.
Unless you can do a window manager in Java (again, that's strongly system dependent, I think).
I can be wrong, of course. (By "not possible" I mean "quite hard".)

Perhaps by explaining what you want to do at a broader level (why open this page in browser), we can help finding workarounds.
Re: Close and or refresh Browser Window
Reply #5 - Mar 9th, 2009, 4:59pm
 
I think if you use the 2nd form of the link command, and use the same "target" each time then it will open the URL in the previously opened window/tab

e.g.
Code:
link("http://www.foo.com","MyWindow");
Re: Close and or refresh Browser Window
Reply #6 - Mar 9th, 2009, 5:30pm
 
Thanks for answering...

I'm using Windows2003 + Explorer 6 or the latest Firefox.
I don't mind "hardcoding" a solution for only this platform. THis is for my use anyway.

Here is the syntax I am using. When activated, it continues to spawn windows...

link("http://mysite.com/myphpprogram.php", "MyWindow" );

I'm amenable to any solution...
     
Re: Close and or refresh Browser Window
Reply #7 - Mar 10th, 2009, 12:01am
 
I guess the target parameter works only when the sketch is run as an applet, in a browser.
Here, you can communicate with JavaScript (in the hosting Web page), so you can manipulate windows like JS does: open new, update, close... as long as the browser still allow it, of course.
Re: Close and or refresh Browser Window
Reply #8 - Mar 10th, 2009, 1:18am
 
Well, let me know what I need to change and I'll try it...
Re: Close and or refresh Browser Window
Reply #9 - Mar 10th, 2009, 1:58pm
 
Well, as I wrote: run the sketch as an applet, in a browser...
Re: Close and or refresh Browser Window
Reply #10 - Mar 10th, 2009, 2:02pm
 
Ok... I hate to say this, but how do you do that? Do you have a snippet of code?
Re: Close and or refresh Browser Window
Reply #11 - Mar 10th, 2009, 3:16pm
 
Processing PDE has a menu for that: File > Export.
It will generate a JAR file and an HTML file embedding the applet.
Re: Close and or refresh Browser Window
Reply #12 - Mar 10th, 2009, 3:29pm
 
ok... I see the jar file. How/what do I do next?
Re: Close and or refresh Browser Window
Reply #13 - Mar 10th, 2009, 3:32pm
 
Never mind... I was using the other export option... I'll check it out...
Page Index Toggle Pages: 1