InnerHTML缓存 [英] InnerHTML Caching

查看:108
本文介绍了InnerHTML缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个asp页面,例如:


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


旁边是一个按钮。当用户点击按钮时我点火了一些javascript


函数doThisWhenButtonClicked(){


document.getElementById(''introText'') .innerHTML =" Hello Everybody";


}


所以点击按钮后,我会看到Hello Everybody。里面的div。


到目前为止没问题。


但是,如果我访问我网站上的其他页面,然后单击后退按钮返回页面 ;大家好已经走了 - 也就是说它没有缓存我假设?


任何人都可以帮忙 - 我正在使用Chrome。


谢谢提前

解决方案

afaik,JavaScript操作的结果没有被缓存(它将使用比保存HTML源代码更多的内存并重新呈现页面)

对不起,真的不明白。所以,如果他们没有缓存,为什么我会看到这种行为,我该如何解决呢?


你想在其中解决什么?所以你想让浏览器记住div中的内容应该在那里,如果我在访问任何其他页面后在浏览器中单击回来?

问候,你为什么要这样做以及为什么你想要仅使用javascript进行该工作?

Omer Aslam


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

解决方案

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


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


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


这篇关于InnerHTML缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆