如题!路由器WEB管理的登录对话框怎么实现?
当在浏览器输入路由器IP地址后,便出现了一个登录对话框!是怎么实现的啊!希望各位知道的能提供一个用JS实现的方法!谢谢了!

解决方案 »

  1.   

    弹出一个页面,然后把父页面关闭!就模拟出了一个小窗口了,点击直接弹出一个对话框,web上是不可能的。
      

  2.   

    做登录页面是可以!我用的是showModalDialog!但是被浏览器给拦截了!就直接跳到首页了!
      

  3.   

    div做的模拟窗口能不能在直接访问首页的时候就弹出来呢?而不是通过点击按钮的方式弹出来!
      

  4.   

    直接似乎不能弹出来!而直接通过点击按钮的方式能弹出模拟窗口来!
    我在网上找了段源码如下!
    <html> 
    <head> 
    <title>LIGHTBOX EXAMPLE</title> 
    <style><!--
    #auth_dialog{display:none;position:absolute;width:300px;height:200px;border:1px #ccc solid;left:450px;top:200px--></style>
    </head> 
    <body>
    <form  name= "tcpip" method="post" action="/goform/form_prtsvrtcpipSet">
    <input type="button" value="Apply New Settings" onclick="return ShowAuthDialog();"/>
    </form>
    <div id=auth_dialog>
    <p>用户名:<input type=text id=userAccount name=userAccount/></p>
    <p>密码:<input type=password id=userPwd name=userPwd/></p>
    <p><input type=button value="登 入" onclick="Auth();" /></p>
    </div>
    <script type=text/javascript>   function ShowAuthDialog(){
          document.getElementById('auth_dialog').style.display = 'block';
          return false;//这里返回false可以让form不被提交,你也可以把submit改为button
       }   function Auth(){
         //使用Ajax处理登入过程
          if(success)//返回是否登入成功
            return true;
         return false;
       }
    </script>
    </body> 
    </html>
      

  5.   

    你改成这样看看那呢,加载的时候就弹出div
    <body onload="ShowAuthDialog()">
      

  6.   

    服务器发送 HTTP 401 头就行了.
      

  7.   

    <%@page contentType="text/html;charset=GBK" %>
    <%
    String authorization= request.getHeader("Authorization"); 
    if( authorization != null )
    {
        sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder(); 
        String parame = new String(
            decoder.decodeBuffer(  
                authorization.substring( 6,authorization.length() )
            )
        );
        String s[] = parame.split(":");
        if( s.length > 0 )
        {
            String user = s[0];
            String pwd  = s[1];
            out.println( user +"|"+ pwd );
            out.println( authorization );
            out.println("<script>        document.cookie.setMaxAge(1);//防止响应的用户密码存在客户端        </script>");
            return;
        }
    }
        response.setStatus(401);
        response.setHeader("WWW-Authenticate", "BASIC realm=\"pwd\"");
        response.setHeader("Cache-Control","no-store");
        response.setDateHeader("Expires",0);%>
      

  8.   

    <%@page contentType="text/html;charset=GBK" %> 
    <% 
    String authorization= request.getHeader("Authorization"); //获取请求头Authorization部分
    if( authorization != null ) 

        sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder(); //BASE64解码对象
        String parame = new String( 
            decoder.decodeBuffer(  
                authorization.substring( 6,authorization.length() ) //跳过前面6个字符("Basic "),获取后面部分
            ) 
        );                                                    //BASE64解码
        String s[] = parame.split(":");                       //根据":"分割字符串,返回一个字符串数组
        if( s.length > 0 ) //可有可无的验证
        { 
            String user = s[0]; //用户名
            String pwd  = s[1]; //密码
            out.println( user +"|"+ pwd ); //演示解码过的用户名和密码
            out.println( authorization );  //演示整个串
            out.println(" <script>        document.cookie.setMaxAge(1);//防止响应的用户密码存储在客户端        </script>"); 
            return; 
        } 

        response.setStatus(401); 
        response.setHeader("WWW-Authenticate", "BASIC realm=\"pwd\""); //pwd是主机名,随便整
        response.setHeader("Cache-Control","no-store"); //防止本页面缓存,也有防止响应的用户密码存储在客户端的作用
        response.setDateHeader("Expires",0); %>