javascript参数传递的问题 用cookie来保存登陆信息然后在页面二根据cookie来做判断 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 说的很明白可是我是初学,cookie不知道怎么写啊 这种情况我一般用Session登陆页:登陆成功:Session["UserName"]=username在第二页判断:if(Session["UserName"]!=null){账号=Session["UserName"].ToString();} 帮忙给个cookie的例子怎么定义怎么保存信息在另一个页面又怎么取? 不用cookie,用传值也可以给你个我写的例子js部分a.htmlvar url = 'print.html?name='+name+'?price='+price+'?bigprice='+bigprice+'?money='+money+'?year='+year+'?month='+month+'?day='+day+'?bigyear='+bigyear+'?useful='+useful+'?bigmonth='+bigmonth+'?bigday='+bigday+'?addinform='+addinform; window.open(url);b.htmlwindow.onload = function(){ document.getElementById("name").innerHTML = GetArgs(window.location.href,"name"); //alert("参数为"+myname); document.getElementById("name2").innerHTML = GetArgs(window.location.href,"name"); document.getElementById("price").innerHTML = GetArgs(window.location.href,"price"); document.getElementById("bigprice").innerHTML = GetArgs(window.location.href,"bigprice"); document.getElementById("money").innerHTML = GetArgs(window.location.href,"money"); document.getElementById("year").innerHTML = GetArgs(window.location.href,"year"); document.getElementById("month").innerHTML = GetArgs(window.location.href,"month"); document.getElementById("day").innerHTML = GetArgs(window.location.href,"day"); document.getElementById("bigyear").innerHTML = GetArgs(window.location.href,"bigyear"); document.getElementById("bigmonth").innerHTML = GetArgs(window.location.href,"bigmonth"); document.getElementById("bigday").innerHTML = GetArgs(window.location.href,"bigday"); document.getElementById("useful").innerHTML = GetArgs(window.location.href,"useful"); document.getElementById("use2").innerHTML = GetArgs(window.location.href,"useful"); document.getElementById("addinform").innerHTML = GetArgs(window.location.href,"addinform");}function GetArgs(params,paramName){ var argsIndex = params.indexOf("?"); var arg = params.substring(argsIndex+1); args = arg.split("?"); var valArg = ""; for(var i =0;i<args.length;i++){ str = args[i]; var arg = str.split("="); if(arg.length<=1) continue; if(arg[0] == paramName){ valArg = arg[1]; } } return valArg;} var url = 'print.html要跳转的页面自己改下 javascript是无法获得session的值的。session是存储在服务端的状态,在本地类似session的东西是cookie。是这样吧我这里只是很简单两个html页面一个打开另一个我只想把输入第一个页面的一个参数传给第二页面里的一个参数,这两个都是<input type="text" value="">没有服务器什么的 cookie 例子function setcookie(cookieName, cookieValue, expires, path, domain, secure) { document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : '');};function getcookie(cookieName) { var cookieValue = ''; var posName = document.cookie.indexOf(escape(cookieName) + '='); if (posName != -1) { var posValue = posName + (escape(cookieName) + '=').length; var endPos = document.cookie.indexOf(';', posValue); if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos)); else cookieValue = unescape(document.cookie.substring(posValue)); } return (cookieValue);}; 求物理地址 如何动态的修改ext fieldset里面的 component,在线等谢谢 javascript子父窗体互相调用问题 用鼠标拖动改变tabletable边框大小,如何实现 如何判断某个 getElementById 存在 高分求解,怎样实现不允许拖入某区域的功能? 在线等,看看这个字符串的简单功能,能否帮我解决一下。 急急急,如何将下拉列表框中的选中的一个值赋给同一个表单中的文本框? 怎样统计出字符串字符'/'或'\'的数量? 使用location.href不跳转页面 求个JS判断语句,不懂JS 请教各位先打印,然后马上关闭页面如何实现?
登陆成功:Session["UserName"]=username在第二页判断:
if(Session["UserName"]!=null)
{
账号=Session["UserName"].ToString();
}
怎么保存信息
在另一个页面又怎么取?
a.htmlvar url = 'print.html?name='+name+'?price='+price+'?bigprice='+bigprice+'?money='+money+'?year='+year+'?month='+month+'?day='+day+'?bigyear='+bigyear+'?useful='+useful+'?bigmonth='+bigmonth+'?bigday='+bigday+'?addinform='+addinform;
window.open(url);b.html
window.onload = function(){
document.getElementById("name").innerHTML = GetArgs(window.location.href,"name");
//alert("参数为"+myname);
document.getElementById("name2").innerHTML = GetArgs(window.location.href,"name");
document.getElementById("price").innerHTML = GetArgs(window.location.href,"price");
document.getElementById("bigprice").innerHTML = GetArgs(window.location.href,"bigprice");
document.getElementById("money").innerHTML = GetArgs(window.location.href,"money");
document.getElementById("year").innerHTML = GetArgs(window.location.href,"year");
document.getElementById("month").innerHTML = GetArgs(window.location.href,"month");
document.getElementById("day").innerHTML = GetArgs(window.location.href,"day");
document.getElementById("bigyear").innerHTML = GetArgs(window.location.href,"bigyear");
document.getElementById("bigmonth").innerHTML = GetArgs(window.location.href,"bigmonth");
document.getElementById("bigday").innerHTML = GetArgs(window.location.href,"bigday");
document.getElementById("useful").innerHTML = GetArgs(window.location.href,"useful");
document.getElementById("use2").innerHTML = GetArgs(window.location.href,"useful");
document.getElementById("addinform").innerHTML = GetArgs(window.location.href,"addinform");
}
function GetArgs(params,paramName){
var argsIndex = params.indexOf("?");
var arg = params.substring(argsIndex+1);
args = arg.split("?");
var valArg = "";
for(var i =0;i<args.length;i++){
str = args[i];
var arg = str.split("=");
if(arg.length<=1) continue;
if(arg[0] == paramName){
valArg = arg[1];
}
}
return valArg;
}
是这样吧我这里只是很简单两个html页面
一个打开另一个
我只想把输入第一个页面的一个参数传给第二页面里的一个参数,这两个都是<input type="text" value="">
没有服务器什么的
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};function getcookie(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};