我的页面顶端有一行是显示登录用户名,原来页面是asp的,动态的这个问题好弄。
现在整站改为生成html的,这个时候问题出来了,顶端这一行也被写成固定的了我想这一行登陆信息改成<script language=javascript src='/Style/isLogin.js'></script>来显示但是js如何读取原来在asp页面写下的cookies?
帮我看下该怎么写。isLogin.js代码如下:document.writeln("<script language=\"javaScript\">");document.writeln("if GetCookie('32528com','login_Name') == ''") -------------------------------->判断是否登陆
document.writeln("{document.write(\"<font class=blue>未登陆</font>\")}");
document.writeln("else {document.write(\"<font class=blue>已登陆</font>\")}");document.writeln("function GetCookie(sMainName,sSubName)"
document.writeln("{"
document.writeln("varsCookieName=sMainName"=";"
document.writeln("varsSubCookieName=(sSubName)?sSubName"=":null;"
document.writeln("varsCookie;"
document.writeln("varsWholeCookie=document.cookie;"
document.writeln("varnValueBegin=sWholeCookie.indexOf(sCookieName);"
document.writeln("if(nValueBegin!=-1)"
document.writeln("{"
document.writeln("varnValueEnd=sWholeCookie.indexOf(";",nValueBegin);"
document.writeln("if(nValueEnd==-1)"
document.writeln("nValueEnd=sWholeCookie.length;"
document.writeln("varsValue=sWholeCookie.substring(nValueBeginsCookieName.length,nValueEnd);//获得Cookie值"
document.writeln("if(sSubCookieName)//多值Cookie"
document.writeln("{"
document.writeln("varnSubValueBegin=sValue.indexOf(sSubCookieName);"
document.writeln("if(nSubValueBegin!=-1)"
document.writeln("{"
document.writeln("varnSubValueEnd=sValue.indexOf("&",nSubValueBegin);"
document.writeln("if(nSubValueEnd==-1)"
document.writeln("nSubValueEnd=sValue.length;"
document.writeln("varsSubValue=sValue.substring(nSubValueBeginsSubCookieName.length,nSubValueEnd);//获得指定的子键值"
document.writeln("returnunescape(sSubValue);"
document.writeln("}"
document.writeln("}"
document.writeln("if(!sSubCookieName)"
document.writeln("returnunescape(sValue);"
document.writeln("}"
document.writeln("returnnull;"
document.writeln("}"
document.writeln("</script\>");例:我用<script language=javascript src='/Style/wel.js'></script>来显示各个时段的提示信息在生成的html页面 是OK的,为什么我上面的isLogin.js不可以用?????wel.js
-------------------
document.writeln("<script language=\"javaScript\">");
document.writeln("<!--");
document.writeln("now = new Date(),hour = now.getHours()");
document.writeln("if(hour < 6){document.write(\"<font class=blue>您还没有睡觉啊?</font>\")}");
document.writeln("else if (hour < 8){document.write(\"<font class=blue>太阳每天都是新的!</font>\")}");
document.writeln("else if (hour < 10){document.write(\"<font class=blue>珍惜机会努力工作!</font>\")}");
document.writeln("else if (hour < 12){document.write(\"<font class=blue>放松下眼睛吧!</font>\")}");
document.writeln("else if (hour < 14){document.write(\"<font class=blue>午休也要落实好!</font>\")}");
document.writeln("else if (hour < 17){document.write(\"<font class=blue>有什么可以帮您的?</font>\")}");
document.writeln("else if (hour < 19){document.write(\"<font class=blue>吃过晚饭了吗?</font>\")}");
document.writeln("else if (hour < 22){document.write(\"<font class=blue>学习是一辈子的事!</font>\")}");
document.writeln("else {document.write(\"<font class=blue>要不要来杯咖啡?</font>\")}");
document.writeln("// -->");
document.writeln("</script\>");