html5 - Autocompletion/Restoring of input form fields that are created dynamically on navigation -


assume have <input> element on html page. when fill in value, navigate forth page , navigate back, value restored:

1) in firefox, whole page state being restored because of bfcache: https://developer.mozilla.org/en-us/docs/working_with_bfcache. (that means state of running script being restored.)

2) in chrome, fast page cache not seem work (so page reset original state), values of input fields being retained.

now if add <input> field dynamically script, in firefox value still restored (because of fact being in restored).

in chrome, however, javascript create <input> field has run again, input field appears brand new engine, meaning no value being restored.

so question is: how implement chrome's functionality 2) dynamically generated <input>s (or how give chrome hint identity of input field).

(one reason why interested in proposed custom elements: https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html. using or polyfills @ https://github.com/mozilla/web-components/blob/master/src/document.register.js or https://github.com/polymer/customelements means 1 going create lot of (input) elements programmatically , user experience should work built-in elements.)

one work around thought of use window.history.replacestate whenever value of input element changes store in browser's history. wondering whether can hook directly browser's autocomplete functionality not have repeatedly call replacestate.

there workaround: instead of storing value (whenever changed) of dynamically generated input in browser history using history api, 1 create 1 static hidden <input> field holds page's state , rely on browser's ability restore value.

instead of using input event on <input> fields detect changes saved in current session's history entry, 1 listen pagehide events save current values. may bit more performant. however, not work storing state in hidden input fields because changes after pagehide event discarded (at least chrome).


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -