刷新后如何保留内容

时间:2017-02-01 05:17:37

标签: javascript html css

我有一个计划页面,它允许用户在特定日期输入他们的活动等。但问题是刷新后,数据将丢失。知道我怎么能解决这个问题吗?

enter code hereYUI().use(
'aui-scheduler',
 function(Y) {
  // code goes here
 YUI().use(
'aui-scheduler',
function(Y) {
 var events = [
  {
    content: 'Partial Lunar Eclipse',
    endDate: new Date(2017, 2, 25, 5),
    startDate: new Date(2017, 2, 25, 1)
  },
  {
    color: "#8d8",
    content: 'Earth Day Lunch',
    disabled: true,
    endDate: new Date(2017, 2, 22, 13),
    meeting: true,
    reminder: true,
    startDate: new Date(2017, 2, 22, 12)
  },
  {
    content: "Weeklong",
    endDate: new Date(2017, 2, 27),
    startDate: new Date(2017, 2, 21)
  }
];

var agendaView = new Y.SchedulerAgendaView();
var dayView = new Y.SchedulerDayView();
var weekView = new Y.SchedulerWeekView();
var monthView = new Y.SchedulerMonthView();

var eventRecorder = new Y.SchedulerEventRecorder();

new Y.Scheduler(
  {
    activeView: weekView,
    boundingBox: '#myScheduler',
    date: new Date(2017, 1, 25),
    eventRecorder: eventRecorder,
    items: events,
    render: true,
    views: [dayView, weekView, monthView, agendaView]
   }
   );
  }
  );
  }
  );

这是从bootstrap中获取的。

1 个答案:

答案 0 :(得分:0)

您可以使用window.sessionStorage

设置项目

window.sessionStorage.setItem('item', value);

获得价值

var itemValue = window.sessionStorage.getItem('item')