could anyone help me out with either some javacode or javascript to add to my html. that when i click exit on my applet is also closes the browser window which the applet is embeded in.
Printable View
could anyone help me out with either some javacode or javascript to add to my html. that when i click exit on my applet is also closes the browser window which the applet is embeded in.
sorry didnt specify earlier that i have already a button in my applet that closes the applet. im not just using the X on the applets window.
applet is run on browser so when you close the applet ...browser will close.
it's not closing the browser window i think because. the applet it self opens a seperate window for the frame of my applet. so it has its own appletviewer window that seperate from the browser window. is there some script to let the browser window know that the applets window has been closed?
Not having crossed this issue myself, checking google gave me this...
rgagnon.com/javadetails/java-0282.html
Have a Java button close the browser window - Real's Java How-to
Hopefully this helps! :DCode:import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import netscape.javascript.*;
public class WinClose extends Applet
implements ActionListener{
Button wc = new Button("Close me");
public void init() {
wc.setActionCommand("CLOSE");
wc.addActionListener(this);
add(wc);
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("CLOSE")) {
JSObject win = (JSObject) JSObject.getWindow(this);
win.eval("self.close();");
}
}
}