SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2010
    0 Post(s)
    0 Thread(s)

    Question How to cache a DHTML updated web page

    If you use javascript/dhtml to, say, add a text field to a web page. If you then navigate away from this page and back again using the back button the added text field is lost and the web page is back to how it was prior to any dhtml changes.

    I assume this is because the browser is using the cached version and not the changed dhtml version.

    How can I force the changed web page to be cached so that when returning to the page the dhtml version is the page I see with the added text field?

  2. #2
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    2 Post(s)
    0 Thread(s)
    You can't. Once the page reloads all original variables are lost. If you want to do this you will need to use one of three possible strategies:
    1: Use a frameset and store the field values in variables in a hidden frame and re-populate the fields on returning to the page.
    2: Transfer the field values as a string of text as part of the location.href and then reconstruct the fields when you get back to the page.
    3: Send the field values as a name/value pairs to a cookie on the client's computer.

    Each method has advantages and disadvantages, but it can be done like this.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts