Answer the question
In order to leave comments, you need to log in
How to inpu save the contents of this field in the state history. History API?
How to save the contents of this field in the state history with each change in the content of the input field.
userText.addEventListener("input", () => {
document.getElementById("char-count").innerHTML = userText.value.length;
saveState(userText);
});
function saveState(object) {
history.pushState({ saved: object }, "Additional information");
}
console.log(history);
history.pushState({foo: 'bar'}, 'Title', '/baz.html')
Answer the question
In order to leave comments, you need to log in
I decided!
Only it is necessary that not by the piece, but the entire field is recorded
userText.addEventListener("input", () => {
document.getElementById("char-count").innerHTML = userText.value.length;
saveState(userText.value);
});
function saveState(object) {
let objectJson = JSON.stringify(object);
history.pushState({ page: objectJson }, "title", "?page");
console.log(history);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question