|
Have a Java button close the browser window |
|
|
This tip shows how to close the browser window when user presses a button.
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();");
}
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.