解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function getQuery(str,m){
    var reg=new RegExp(m+'=(.*?)(;|$)');
    var arr=reg.exec(str);
    return arr==null?'':arr[1];
    }
    var str='JS_SESSIONID=3fkxy74jrhl6psiadlv8ljdr2erpatjc;S[L_RANDOM_CODE]=e1f979ea2b94f4a754835ee9f85cf0d0;S[loginName]=alice;S[MEMBER]=4-6384e2b2184bcbf58eccf10ca7a6563c-45933f1b8e719336f3dbb1b51493c7f7-1322653860; S[UNAME]=alice';
    alert(getQuery(str,'JS_SESSIONID'));
    alert(getQuery(str,'S\\[L_RANDOM_CODE\\]'));
    alert(getQuery(str,'S\\[loginName\\]'));
    alert(getQuery(str,'S\\[MEMBER\\]'));
    alert(getQuery(str,'S\\[UNAME\\]'));
    </script>
    </head><body>
    </body>
    </html>