Reputation: 31
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
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
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