javascript - IE 11 browser not storing form data. I need to store page_is_dirty flag for page visited. My code is working fine in chrome only -


i need detect page dirty flag in application.

i used:

<form name="ignore_me">     <input type="text" value="0" id='page_is_dirty' name='txt' style="display: none" />  </form> 

to set flag in html:

<script>     var dirty_bit = document.getelementbyid('page_is_dirty');     if (dirty_bit.value == '1') {         //some 1 went other site , came using button         alert('on button , dirty page.');         callwicket();     }     //first time page load mark dirty     function mark_page_dirty() {         dirty_bit.value = '1';         alert('in 3 dirty_bit = ' +dirty_bit.value);     };     mark_page_dirty();     alert('in 4 dirty_bit = ' +dirty_bit.value); </script> 

this keep value 1 when again visited same page clicking button if user click on url other application url , press button come again in application.

but kept value 1 in chrome. in ie 11 it's not keeping old value 1 , reload form data , set again 0.

i need stored form data in ie . there way page_is_dirty value form data?

well getting , setting form values you've done correct, simplified like:

<form id="test">     <input id="dirty" type="hidden" value="no" /> </form>  <script>     function isdirty() {         var dirty = document.getelementbyid("dirty").value;         return (dirty === "yes");     }      function setdirty(dirty) {         document.getelementbyid("dirty").value = (dirty) ? "yes" : "no";     }      console.log("dirty?", isdirty());     setdirty(true);     console.log("dirty?", isdirty()); </script> 

but keeping state between page loads, perhaps consider using localstorage instead of form:

<script>     function isdirty() {         var dirty = window.localstorage.getitem("page_dirty");         return (dirty === "yes");     }      function setdirty(dirty) {         window.localstorage.setitem("page_dirty", (dirty) ? "yes" : "no");     }      console.log("dirty?", isdirty());     setdirty(true);     console.log("dirty?", isdirty()); </script> 

that way, state there between page loads of same site. if absolutely required, combine these update form value when setting.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -