새로 고침 후 localStorage 값을 html로 유지하는 방법은 무엇입니까?
var btn = document.getElementById('insert'),
s = 0; //To increment the key(+1) each time the button is clicked and the user inputs the values so the first object's key is 1 then the second one is 2 and so on
btn.addEventListener('click', function() {
var ModelMake = prompt("Enter The Model Make"),
ModelYear = prompt("Enter The Model Year"),
Km = prompt("Enter The Amount Of Km"),
Price = prompt("Enter The Price"),
Status = prompt("Enter The Car's Status"),
table = document.getElementById('table');
var tableout = document.getElementById('tableout'),
FinalPrice,
Details;
localStorage.setItem(s += 1, JSON.stringify({
ModelMake: ModelMake,
ModelYear: ModelYear,
Km: Km,
Price: Price,
Status: Status,
FinalPrice: FinalPrice,
Details: Details
}));
이 코드의 행에서 다음 변수 값 (사용자 입력들을) 삽입하고 난 때 물체에도 로컬 스토리지에 저장된 리프레쉬 할 때마다 값은 컬럼 (셀)에 분명히 내 브라우저를 닫습니다하지만 내가 어떻게 새로 고침 또는 localStorage에서 그것을 추출하지 않고도 브라우저를 닫을 지 여부를 html로 유지하는 방법을 원한다.
난 당신이 정확하게 원하는 것을 이해하지 않습니다. localStorage에 저장하지만 아무 것도하지 않으려 고합니까? – Marciano
수 없습니다. HTTP 요청은 이전 상태를 기억하지 못하기 때문에 일종의 브라우저 나 데이터베이스 저장소가 필요합니다. 새로 고침하고 닫은 후에 데이터를 보관하기 때문에'localStorage'를 계속 사용하는 것이 좋습니다. 내가 본 것처럼 * "나는 쿠키 항아리를 열지 않고 쿠키를 얻고 싶다"*, 질문 유형입니다. –