Back Button Handle A Dynamic Form

后端 未结 6 1092
旧时难觅i
旧时难觅i 2020-12-28 17:17

I have a form with an array of text fields. The user (through javascript) can add an arbitrary number of text fields to the form. After submitting the form and pressing th

6条回答
  •  自闭症患者
    2020-12-28 17:46

    In good browsers you can have it working perfectly simply by not breaking it.

    Firefox 1.5 uses in-memory caching for entire Web pages, including their JavaScript states, for a single browser session. Going backward and forward between visited pages requires no page loading and the JavaScript states are preserved. source

    This is supported in Opera and WebKit too. However DOM cache is only possible in you stick to the rules:

    1. Don't use onunload, onbeforeunload.
    2. Don't use Cache-control: no-store or must-revalidate.
      In PHP you must change session.cache_limiter from patently_ridiculous (I think they spell it nocache) to none.

      session_cache_limiter('none');
      
    3. Unfortunately HTTPS is also out.

    If you don't force browsers to reload the page, they won't. They'll keep the DOM and its values unchanged, exactly as RFC 2616 suggests.


    However, if you're looking for place to stash the data, there's incredibly clever hack – window.name can store megabytes of data. It's not sent to server, and it isn't shared between windows.

    There are also Flash cookies and HTML 5 localStorage is implemented in IE8 and Safari 4.

提交回复
热议问题