admin管理员组文章数量:1431994
I have one HTML file containing several <div>
elements. I want to refresh just part of the page using either JavaScript or C#. Can someone help?
I am trying to do it this way:
document.location.reload(document.getElementById("contentdiv"));
It reloads the whole page. I wish to reload contentdiv
. If contentdiv
is at the middle of the page then it should load only that part.
Thank you.
I have one HTML file containing several <div>
elements. I want to refresh just part of the page using either JavaScript or C#. Can someone help?
I am trying to do it this way:
document.location.reload(document.getElementById("contentdiv"));
It reloads the whole page. I wish to reload contentdiv
. If contentdiv
is at the middle of the page then it should load only that part.
Thank you.
Share Improve this question edited Apr 18, 2011 at 23:16 openai_sucks 1,2731 gold badge15 silver badges25 bronze badges asked Apr 18, 2011 at 22:26 PruthvidPruthvid 68310 silver badges19 bronze badges2 Answers
Reset to default 5You could move the contents of everything you want reloaded into an external file, and either use the <iframe>
tag and only refresh that frame, or you could use JavaScript and refresh the div with Ajax.
Ajax isn't that simple to explain in a short answer, but you can find plenty of information on it here: http://www.w3schools./Ajax/ajax_example.asp or if you use a framework like jQuery ajax is much easier.
iFrames can be implemented (on mypage.html, for example) like so: <iframe src='mypagecontent.html'></iframe>
and in mypagecontent.html you could use <script type='text/javascript'>window.location.reload();</script>
to refresh the frame.
Not sure if this is what you're looking for, but hope it helps somewhat.
What ASP.NET Framework are you using? If you are using Web Forms, look into UpdatePanel
本文标签: cHow to refresh just a specific portion of an HTML pageStack Overflow
版权声明:本文标题:c# - How to refresh just a specific portion of an HTML page? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745572202a2664112.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论