在页面里写个html按钮,
用javascript关闭浏览器就是了!

解决方案 »

  1.   

    但是页面里面怎么写html文件呢?
      

  2.   

    System.exit(0);
    同时还要进行安全验证
      

  3.   

    你这样做吧:applet 代码:(CloseIE.java)
    ===============================================================================
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;public class CloseIE extends Applet  {
        public Button closeButton = new Button("Close");
    public void init() {
        this.setLayout(null);
        closeButton.setBounds(30, 40, 60, 20);
        closeButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        close();
    }
        });
        this.add(closeButton);
    }
        public void close() {
    try {
        this.getAppletContext().showDocument(new URL(this.getCodeBase()
                                   + "1.html"), "main");
    }
    catch(MalformedURLException e) {
        System.out.println("error");
    }
        }
    }CloseIE.html文件
    ===========================================================================
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>
    Close Test
    </title>
    </head>
    <body>
    <iframe name="main" height=0></iframe>
    <p align=center>
    <BR>
    <applet
    codebase = "."
    code     = "CloseIE.class"
    width    = "120"
    height   = "100"
    hspace   = "0"
    vspace   = "0"
    align    = "middle"
    >
    </applet>
    </body>
    </html>1.html文件
    ===========================================================================
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>
    Close Test
    </title>
    </head>
    <body>
    <p align=center>
    <script language="javascript">
    parent.opener = null;
    parent.close();
    </script>
    <BR>
    test!!
    </body>
    </html>放同一目录,编译后运行CloseIE.html