使用JavaScript重新加载div的内容 [英] reload contents of div using javascript

查看:428
本文介绍了使用JavaScript重新加载div的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在按钮单击时重新加载 div 标记的内容。我可以这样做:

I'm trying to reload the contents of div tag on button-click. I can do it with using:

function reload_div()
{   
    document.getElementById('div_id').innerHTML = 'blah blah blah';
}

但问题是, div 标签包含数千行,当我尝试使用以前的函数来实现div加载时,浏览器将被冻结。我正在寻找一个解决方案,但我发现所有使用ajax或jquery,我没有使用过这些库之前。那么,我可以使用javascript和html重新加载div内容吗?感谢。

but the problem is, that div tag contains thousands of lines and when I try to acomplish the div-reloading with previous function, the browser will be freezed. I was searching for a solution on stackoverflow but all what I found is with using ajax or jquery and I haven't used those library before. So, can I reload the div contents using javascript and html only? Thanks.

推荐答案

我不确定为什么您想首先使用JavaScript加载如此多的内容,但是您总是可以将JavaScript放在外部文件中,以便浏览器可以缓存它。这应该有助于如果浏览器加载导致页面冻结的脚本。

I'm not sure why you would want to load so much content with javascript in the first place, but you could always put the javascript in an external file so the browser could cache it. That should help if it's the browser loading the script that is causing the page to freeze up.

随时发布更多代码,我会看看如果不不要为你做。

Feel free to post more code and I'll take a look if that doesn't do it for you.

这篇关于使用JavaScript重新加载div的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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