注册 登录
编程论坛 J2EE论坛

页面问题??

luyihuaa5201 发布于 2008-05-12 10:06, 607 次点击
怎么写个东西,一进页面就加载javascript中的方法。
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>测试页面</title>

        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

    </head>
<script language="JavaScript">
function info(){
    var linkDesc ;
       linkDesc=window.location.href;
    var num1 = linkDesc.indexOf("=") ;
    var num2 = linkDesc.indexOf("&") ;
    var num3 = linkDesc.indexOf("password=");
    var num4 = linkDesc.indexOf("&profileid");
    var userName = linkDesc.substring(num1+1,num2);
    var passWord = linkDesc.substring(num3+9,num4);
       <%session.setAttribute("login",'%>userName<%');%>
    }
</script>
    <body onload="info();">
    
    </body>
    <%
      request.getRequestDispatcher("login.jsp").forward(request,response);
    %>
</html>

我这个页面就是把浏览器获得的用户名密码存起来就可以了。
0 回复
1