Trying to disable a button on another page by pressing a button on this page.
WHAT I TRIED: Right now when the button is pressed it creates a function and the function says this
function createItem() {
localStorage.test1 = document.getElementById("hello").buttonDisabled="disabled";
}
On the other page i have another button which has a function which gets that saved item from local storage and applies it to the button to disable it. I know thats working properly
localStorage.test1 = document.getElementById("hello").buttonDisabled="disabled";
I just need help on changing this part "buttonDisabled="disabled"" so it actually disables the button instead of what its currently doing which is just changing the text thats on the button. Also the codepen link for this is https://codepen.io/haroon1233212/pen/XWVqrbe the code you need to change is at the bottom of the page in the javascript section
CodePudding user response:
put eval(localstoarge.mycode) Just put eval befor localstorage which maked it run the code
CodePudding user response:
You can add listeners on the localStorage. https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event I would suggest you store a boolean and on startup on your page you add a listener.