user989805
user989805

Reputation: 31

Redirect after java applet is run?

I have googled around but have not come to an answer. The only thing close to my goal was utilizing meta redirect after X seconds, like so:

<meta http-equiv="refresh" content="5;url=index2.html">

What I need is php or html code that detects if my java applet has been run on the page, and then redirects to another file address.

How might I go about this, can someone be so kind as to throw me an example code? Very much appreciated, thank you kindly for your time.

Upvotes: 1

Views: 2178

Answers (2)

sukanta
sukanta

Reputation: 51

If you want to redirect from your applet then write the code below:

import java.applet.*;
import java.awt.Graphics;
import java.net.MalformedURLException;
import java.net.URL;

public class AppletExample extends Applet
{

public void init() {

try {
getAppletContext().showDocument(new URL("http://www.google.com"), "_blank");//This is new tab/
getAppletContext().showDocument(new URL("http://www.google.com"), "_parent");//This is in the parent tab/
}
catch (MalformedURLException ex) {
System.out.println(ex.getMessage());
}
}

public void paint( Graphics g ) {

g.drawString("Go Google", 0,100);
}

}

Upvotes: 3

Mads
Mads

Reputation: 724

If you want the redirect triggered from within the applet I would try with the showDocument(). It can be used like this:

this.getAppletContext().showDocument(URL, "_parent");

Upvotes: 0

Related Questions