window.open("Index.html"); 
window.opener = "meizz";   //IE5.5+ 没有关闭提示
window.close();

解决方案 »

  1.   

    这是我的 登陆窗体的代码:
    提交表单到本页,然后根据登陆情况判断,如果登陆成功,则
    Response.sendRedirect("");到其他页面,否则,关闭。<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
    <jsp:useBean id="login" class="password.PassWord" scope="page"/><html><head>
    <title>登陆系统</title>
    <script language="javascript">
    function IsValidString(checkStr)
    {
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
    var allValid = true;
    if (checkStr.length<1)
     allValid=false;
      for (i=0;i<checkStr.length;i++)
      {
        ch=checkStr.charAt(i);
        for(j=0;j<checkOK.length;j++)
          if(ch==checkOK.charAt(j))
            break;
        if(j==checkOK.length)
        {
          allValid = false;
          break;
        }
      }
      return allValid;
    }
    function checkform(){   if(document.form1.username.value=="")
      {
           alert("请填写用户名!");
       return false;
      }
       if(document.form1.password.value=="")
      {
           alert("请填写密码!");
       return false;
      }
    if (!IsValidString(document.form1.password.value))
    {
    alert("对不起,不能使用汉字或非法字符当作密码!");
      document.form1.password.focus();
        return false;
    }
    }
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }function CloseWindow()
    {
             window.close();
    }</script></head><body>
    <%
              String loginName="",passWrd="",liShuBuMen="",isAdmin="",realName="",bmfId="",bmId="";
             
    %>                  <%
                                        loginName=request.getParameter("name");
                                        passWrd=request.getParameter("pass");
                                        if(loginName!=null)
                                        {
                                              ResultSet temp=login.queryExe("select P.*,T.bmfId,T.bmId from PassWord P ,TBuMen T where LoginName='"+loginName+"'"+
                                                                            " and PassWrd='"+passWrd+"' and P.liShuBuMen=T.bmId");
                                              if(temp.next())
                                              {
                                                   
                                                      liShuBuMen=temp.getString("LiShuBuMen");
                                                      isAdmin=temp.getString("IsAdmin");
                                                      realName=temp.getString("RealName");
                                                      bmfId=temp.getString("bmfId");
                                                      bmId=temp.getString("bmId");                                                  session.setAttribute("loginName",loginName);
                                                      session.setAttribute("isAdmin",isAdmin);
                                                      session.setAttribute("realName",realName);
                                                      session.setAttribute("LiShuBuMen",liShuBuMen);
                                                      session.setAttribute("BuMenId",bmId);
                                                      
                                                      if(isAdmin.equals("1"))
                                                      {
                                                            response.sendRedirect("Administrator.jsp?department="+liShuBuMen);                                                                    
                                                      }
                                                      else
                                                      {
                                                        if(liShuBuMen.equals("6"))
                                                       {            
                                                              response.sendRedirect("JiWuDuanIndex.jsp");
                                                       }
                                                       else if(liShuBuMen.equals("4")||bmfId.equals("4"))
                                                       {
                                                             
                                                              response.sendRedirect("AnQuanFuZhangIndex.jsp");
                                                       }
                                                       else if(liShuBuMen.equals("3"))
                                                       {                                                         
                                                              response.sendRedirect("YunYongFuZhangIndex.jsp");
                                                       }
                                                       else if(liShuBuMen.equals("2")||bmfId.equals("2"))
                                                       {                                                         
                                                             response.sendRedirect("ZongGongIndex.jsp");
                                                       }
                                                        else if(liShuBuMen.equals("1"))
                                                       {                                                         
                                                             response.sendRedirect("DuanZhangIndex.jsp");
                                                       }
                                                        else if(liShuBuMen.equals("5"))
                                                        {
                                                                    response.sendRedirect("JianXiuFuZhangIndex.jsp");       
                                                        }
                                                      }              
                                              }
                                              else
                                              {
                         %>
                         <script>
                                
                                window.alert("用户名或密码错误");
                                window.close();
                                
                         </script>
                         <%
                                              }
                                        }
                         %> 
    <table width="409" >
    <form name="form1" action="LoginTest.jsp" method="post">
    <td width="389" align="center">
    <p align="center"><font color="#0000FF"><b>登陆系统</b></font></p>
    <div align="center">
      <center>
      <table border="1" width="297" height="106" cellspacing="0">
        <tr>
          <td width="75" height="35" valign="middle">姓名:</td>
          <td width="206" height="35" valign="middle"><input type="text" name="name" size="28"></td>
        </tr>
        <tr>
          <td width="75" height="35" valign="middle">密码:</td>
          <td width="206" height="35" valign="middle"><input type=password name="pass" </td size="28">
        </tr>
        <tr>
          <td width="297" height="36" colspan="2" valign="middle">
            <p align="center"><input type=submit value=" 登录 ">&nbsp;<input type="reset" value=" 重写 "></td>
        </tr>
      </table>
      </center>
    </div>
    </table>
    </form>
    </body></html>
      

  2.   

    重新在贴一次,上面的比较乱,这次的好一点!!!<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
    <jsp:useBean id="login" class="password.PassWord" scope="page"/><html><head>
    <title>登陆系统</title>
    <script language="javascript">
    function IsValidString(checkStr)
    {
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
    var allValid = true;
    if (checkStr.length<1)
     allValid=false;
      for (i=0;i<checkStr.length;i++)
      {
        ch=checkStr.charAt(i);
        for(j=0;j<checkOK.length;j++)
          if(ch==checkOK.charAt(j))
            break;
        if(j==checkOK.length)
        {
          allValid = false;
          break;
        }
      }
      return allValid;
    }
    function checkform(){   if(document.form1.username.value=="")
      {
           alert("请填写用户名!");
       return false;
      }
       if(document.form1.password.value=="")
      {
           alert("请填写密码!");
       return false;
      }
    if (!IsValidString(document.form1.password.value))
    {
    alert("对不起,不能使用汉字或非法字符当作密码!");
      document.form1.password.focus();
        return false;
    }
    }
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }function CloseWindow()
    {
             window.close();
    }</script></head><body>
    <%
              String loginName="",passWrd="",liShuBuMen="",isAdmin="",realName="",bmfId="",bmId="";
             
    %>
     <%
              loginName=request.getParameter("name");
              passWrd=request.getParameter("pass");
              if(loginName!=null)
              {
                    ResultSet temp=login.queryExe("select P.*,T.bmfId,T.bmId from PassWord P ,TBuMen T where LoginName='"+loginName+"'"+
                                         " and PassWrd='"+passWrd+"' and P.liShuBuMen=T.bmId");
                    if(temp.next())
                    {
                                                   
                         liShuBuMen=temp.getString("LiShuBuMen");
                         isAdmin=temp.getString("IsAdmin");
                         realName=temp.getString("RealName");
                         bmfId=temp.getString("bmfId");
                         bmId=temp.getString("bmId");                     session.setAttribute("loginName",loginName);
                         session.setAttribute("isAdmin",isAdmin);
                         session.setAttribute("realName",realName);
                         session.setAttribute("LiShuBuMen",liShuBuMen);
                         session.setAttribute("BuMenId",bmId);
                                                      
                         if(isAdmin.equals("1"))
                         {
                                response.sendRedirect("Administrator.jsp?department="+liShuBuMen);                                                                    
                         }
                         else
                         {
                                if(liShuBuMen.equals("6"))
                                {            
                                       response.sendRedirect("JiWuDuanIndex.jsp");
                                }
                                else if(liShuBuMen.equals("4")||bmfId.equals("4"))
                                {
                                                             
                                       response.sendRedirect("AnQuanFuZhangIndex.jsp");
                                }
                                else if(liShuBuMen.equals("3"))
                                {                                                         
                                       response.sendRedirect("YunYongFuZhangIndex.jsp");
                                }
                                else if(liShuBuMen.equals("2")||bmfId.equals("2"))
                                {                                                         
                                       response.sendRedirect("ZongGongIndex.jsp");
                                }
                                else if(liShuBuMen.equals("1"))
                                {                                                         
                                       response.sendRedirect("DuanZhangIndex.jsp");
                                }
                                else if(liShuBuMen.equals("5"))
                                {
                                       response.sendRedirect("JianXiuFuZhangIndex.jsp");       
                                }
                        }              
                   }
                   else
                   {
                         %>
                         <script>
                                
                                window.alert("用户名或密码错误");
                                window.close();
                                
                         </script>
    <%
                   }
              }
    %> 
    <table width="409" >
    <form name="form1" action="LoginTest.jsp" method="post">
    <td width="389" align="center">
    <p align="center"><font color="#0000FF"><b>登陆系统</b></font></p>
    <div align="center">
      <center>
      <table border="1" width="297" height="106" cellspacing="0">
        <tr>
          <td width="75" height="35" valign="middle">姓名:</td>
          <td width="206" height="35" valign="middle"><input type="text" name="name" size="28"></td>
        </tr>
        <tr>
          <td width="75" height="35" valign="middle">密码:</td>
          <td width="206" height="35" valign="middle"><input type=password name="pass" </td size="28">
        </tr>
        <tr>
          <td width="297" height="36" colspan="2" valign="middle">
            <p align="center"><input type=submit value=" 登录 ">&nbsp;<input type="reset" value=" 重写 "></td>
        </tr>
      </table>
      </center>
    </div>
    </table>
    </form>
    </body></html>
      

  3.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>子父窗口的操作</title>
    </head>
    <body>
    <script>
    var win=null;
    function op(){
    win=window.open("about:blank","win","width=200,height=200");
    win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close()'>");
    win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");
    }
    </script>
    <input onclick="op()" value="打开窗口" type="button"><input type="button" value="最小化" onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else alert('还没有打开窗口或已经关闭')"><input type="button" value="最大化" onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else alert('还没有打开窗口或已经关闭');"><input type=button value="关闭子窗口" onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')"><input type=button value="刷新子窗口" onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')"><input type="button" value="看子窗口的大小" onclick="if(win&&win.open&&!win.closed){alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert('还没有打开窗口或者已关闭')};">
    </body>
    </html>