473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

InnerHTML Caching

83
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 doThisWhenButtonClicked() {

document.getElementById('introText').innerHTML = "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
Dec 6 '11 #1
12 2376
Dormilich
8,658 Expert Mod 8TB
afaik, results of JavaScript operations ain’t cached (it would use way more memory than saving HTML source code and render the page anew)
Dec 6 '11 #2
TimSki
83
sorry don't really understand. so if they are not cached why do i see that behaviour and how can i resolve it ?
Dec 6 '11 #3
omerbutt
638 512MB
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
Dec 6 '11 #4
TimSki
83
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.
Dec 6 '11 #5
Dormilich
8,658 Expert Mod 8TB
why would they need to go back to see the result of what they just did?
Dec 6 '11 #6
TimSki
83
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
Dec 7 '11 #7
Dormilich
8,658 Expert Mod 8TB
then you need to disable either caching or going back, because HTTP is a stateless protocol that doesn’t automatically update itself.
Dec 7 '11 #8
TimSki
83
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 :(
Dec 7 '11 #9
Dormilich
8,658 Expert Mod 8TB
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 …)
Dec 7 '11 #10
TimSki
83
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
Dec 7 '11 #11
acoder
16,027 Expert Mod 8TB
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 "intelligent" 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.
Dec 7 '11 #12
Rabbit
12,516 Expert Mod 8TB
What if you used the onload event to update the data?
Dec 7 '11 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using...
0
by: Troy Simpson | last post by:
Hi, I have a website which is made up of dynamic pages. Each page that's loaded has some code which looks at which template to load amongst other things, which causes the page to take a little...
5
by: kaczmar2 | last post by:
I have a page written in ASP.NET that uses some Javascript to modidy the .innerHTML property of a DIV tag. The page works great in FireFox, but in IE6, the page tends to pull the content out of...
7
by: Jake Barnes | last post by:
I've a little webcam program that snaps a picture of me and uploads it every 20 seconds. It automatically uploads the image to my server. It always give the image the same name, and thus it...
9
by: Hallvard B Furuseth | last post by:
Why does the FAQ (Q 4.15) recommend innerHTML when so many here say one should use createElement(), replaceChild() etc? Also, why does the "Alternative DynWrite function" at...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
4
by: Hermann | last post by:
My site is a bit slow showing the main page so I thought caching query result in PHP will improve performace. Then I read MySQL documentation and saw that MySQL does have a caching feature. So......
9
by: martymix | last post by:
simple question: I have a simple <dt>test text</dt> I get the innerHTML of that dt, and I try and append some text to it like so: dt = document.getElementsByTagName('dt') var text =...
1
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm...
1
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.