[英]Key Value pair for cookies
I am having an image icon which on clicking should navigate to the other page 我有一个图像图标,单击该图标应导航到另一页
' <input type="image" id="dataReview_' + templates[i].dataFileKey + '" title="Data Review" src="Images/datareview.png" style="height: 15px; width: 15px" onclick="dataReview_tasks(this); return false;"/>\n' +
In dataReview_tasks() function below 在下面的dataReview_tasks()函数中
function dataReview_tasks(inputOb)
{
var info = new IOInfo(inputObj);
var id = info.key(0);
var tdLastDateId = "lastRun_" + id;
var decoded_lastRunDate = decodeURIComponent(trim($("#" + tdLastDateId).text())).split(" ")[0];
var lastRunDate = encodeURIComponent(decoded_lastRunDate);
window.location('<%= ResolveUrl("~/GUI/DataReviewNEW.aspx") %>');
I should be making the ID and the lastRunDate as cookies. 我应该将ID和lastRunDate设置为cookie。 How can I approach this.
我该如何处理。
I am not sure why it is not holding the value 54 while I am debugging, I am new Javascript and not sure if I am giving them properly in document.cookie Any help is greatly appreciated 我不确定在调试时为什么它没有保持值54,我是新Javascript,也不确定是否在document.cookie中正确地赋予了它们任何帮助,我们将不胜感激
function dataReview_tasks(inputOb){
var info = new IOInfo(inputObj);
var id = info.key(0);
var tdLastDateId = "lastRun_" + id;
var decoded_lastRunDate = decodeURIComponent(trim($("#" + tdLastDateId).text())).split(" ")[0];
var lastRunDate = encodeURIComponent(decoded_lastRunDate);
var tCookiename = '<%= this.CookieDataFileKey %>'; //This is your '$DataFileKey' placeholder from codebehind
var tCookievalue = {id: id, lastRunDate: lastRunDate}; //Since there are two values, we are passing an object.
//Setting the actual cookie
document.cookie = [tCookiename, JSON.stringify(tCookievalue)].join('=');
window.location('<%= ResolveUrl("~/GUI/DataReviewNEW.aspx") %>')
}
function readCookie(n){
var tC = document.cookie || '';
tS = tC.split(n + '=').pop().split(';')[0];
return JSON.parse(tS)
}
readCookie('$DataFileKey')
Yes, of course the values can be set seperately: 是的,当然可以分别设置这些值:
//Settings '$DataFileKey'
document.cookie = ['<%= this.CookieDataFileKey %>', id].join('=');
//Settings '$DataWhatever'
document.cookie = ['<%= this.CookieDateCompleteEnd %>', lastDateRun].join('=');
function readCookie(n){
return (document.cookie || '').split(n + '=').pop().split(';')[0]
}
readCookie('$DataFileKey')
使用以下代码:
document.cookie = "$(<%= this.CookieDataFileKey %>) =" + id +'"';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.