InnerHTML Caching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimSki
    New Member
    • Jan 2008
    • 83

    InnerHTML Caching

    Hi,

    I have an asp page with for example:

    <div id="introText"> </div>

    next to this is a button. when then user clicks on the button I fire some javascript

    function doThisWhenButto nClicked() {

    document.getEle mentById('intro Text').innerHTM L = "Hello Everybody";

    }

    so once the button is clicked I see "Hello Everybody" inside the div.

    No problem so far.

    However if i visit another page on my site and then click the back button to return to the page "Hello Everybody" has gone - ie it's not cached i assume ??

    Can anyone help - i'm using Chrome.

    Thanks on advance
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    afaik, results of JavaScript operations ain’t cached (it would use way more memory than saving HTML source code and render the page anew)

    Comment

    • TimSki
      New Member
      • Jan 2008
      • 83

      #3
      sorry don't really understand. so if they are not cached why do i see that behaviour and how can i resolve it ?

      Comment

      • omerbutt
        Contributor
        • Nov 2006
        • 638

        #4
        what do you want to resolve in it ? so you want the browser to remember what ever was inside the div should be there if i click back in the browser after visiting any other page?
        regards, why would you want to do that and why you want to use javascript only for that work?
        Omer Aslam

        Comment

        • TimSki
          New Member
          • Jan 2008
          • 83

          #5
          ok bit more detail - my site lists property. On each advert there is an 'add to your selection' link. When they click on this the text is changed into 'The advert has been added to your selection' (This is the text inside the div). They then click on the tab 'My selection' where they see the advert selected. they then go back to the listing by clicking on the back button and see the advert they selected now says 'add to your selection' which is clearly confusing for them.

          hope this makes sense and gives a bit more insight into why I'm trying to solve this.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            why would they need to go back to see the result of what they just did?

            Comment

            • TimSki
              New Member
              • Jan 2008
              • 83

              #7
              they're not going back to see what they did especially, it's just that they return to the listing page to carry on looking down the adverts. it's not something that happens a lot but it does happen and it causes problems (these are paying customers) so it would be nice to find a solution

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                then you need to disable either caching or going back, because HTTP is a stateless protocol that doesn’t automatically update itself.

                Comment

                • TimSki
                  New Member
                  • Jan 2008
                  • 83

                  #9
                  yes thanks but i realise that. going back can't (or shouldn't) be disabled and disabling caching will cause other problems i'm sure (also not great practice). i was hoping there was another solution but maybe not :(

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    you could tell your customers that they have to refresh the page in case they were going back and want to see their advert added. (I mean, there a a lot of not tech-savvy people, but going back in the browser and expecting to see changes made otherwhere …)

                    Comment

                    • TimSki
                      New Member
                      • Jan 2008
                      • 83

                      #11
                      yes its'a good thought but I have plenty of experience with people seemingly unable to read instructions ;) ! A tech soln would be the best if possible

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        There are one or two possibilities, e.g. adding # (hash) to take back control of the back button. This is usually used for Ajax, but you could possibly use it here, but I wouldn't know how useful it'd be and if it would affect anything else in your site.

                        Another possibility is a periodic Ajax call to update the listing. You could make it more "intelligen t" by only updating if there's been a change after the initial request.

                        I'm not saying any of these are good solutions or even if they'll work, but just a couple of ideas to explore.

                        Comment

                        • Rabbit
                          Recognized Expert MVP
                          • Jan 2007
                          • 12517

                          #13
                          What if you used the onload event to update the data?

                          Comment

                          Working...