When the window is loaded, a click Listener event is added to the predefined button to store the session; ShowSession function realizes session display
Window.onload=function () {
document.getElementById ("button"). AddEventListener ("click", Storesession,false);
ShowSession ();
}
Second, the StoreSession function realizes the storage of the session
function StoreSession () {
var A=document.getelementbyid ("Stuno"). Value;
var B=document.getelementbyid ("name"). Value;
Sessionstorage.setitem (A, b);
ShowSession ();
}
Three, the ShowSession function realizes to the session the display
function ShowSession () {
document.getElementById ("Rightbox"). InnerHTML = "";
for (Var i=0;i<sessionstorage.length;i++) {
var aa=sessionstorage.key (i);
var bb=sessionstorage.getitem (AA);
document.getElementById ("Rightbox"). InnerHTML +=aa+ "' s name is" +bb+ "<br/>";
}
Console (sessionstorage.length);
}
Four, so that the JS part is completed, only close the browser, sessionstorage content will be emptied, otherwise there has been.
Usage of sessionstorage in Google_chrome browser