div在asp.net中自动刷新 [英] div auto refresh in asp.net
本文介绍了div在asp.net中自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div name="divname" id="divname">
<asp:Literal ID="msg_disp" runat="server" /></div></td>
</tr>
我需要在asp.net中自动刷新...
i need auto refresh in asp.net...
推荐答案
您可以简单地使用AJAX或JQuery来实现相同的功能.
我只是找到了一个与您正在寻找的完全相同的简单示例.
使用jQuery每10秒自动加载和刷新Div. [^ ]
You can simple use, AJAX or JQuery to achieve the same.
I just found one simple example exactly to what you were looking for.
Auto Load and Refresh Div every 10 Seconds with jQuery.[^]
尝试一下:
try this:
<html>
<body>
<script type="text/javascript">
function Ajax(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
setTimeout('Ajax()',10000);
}
}
xmlHttp.open("GET","http://www.example.com/the_page_that_contains_the_div_content",true);
xmlHttp.send(null);
}
window.onload=function(){
setTimeout('Ajax()',10000);
}
</script>
<div id="ReloadThis">Default text</div>
</body>
</html>
希望对您有所帮助:)
有关进一步的查询,请在此处进行评论!
hope it helps :)
for further queries comment here!
& lt; script type ="text/javascript">
<!-
/*
具有时间脚本的自动刷新页面
通过JavaScript Kit(javascriptkit.com)
这里有200多个免费脚本!
*/
//输入刷新时间(以分钟:秒"为单位),分钟应在0到inifinity的范围内.秒数的范围应从0到59
var limit ="0:10"
如果(document.images){
var parselimit = limit.split(:")
parselimit = parselimit [0] * 60 + parselimit [1] * 1
}
函数beginrefresh(){
如果(!document.images)
返回
if(parselimit == 1){
window.document.forms [0] .submit();
}
其他{
parselimit-= 1
curmin = Math.floor(parselimit/60)
cursec = parselimit%60
如果(curmin!= 0)
curtime = curmin +分钟和" + cursec +秒,直到页面刷新为止!"
其他
curtime = cursec +距离页面刷新还剩秒!"
window.status = curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload = beginrefresh
//->
& lt;/script>
<script type="text/javascript">
<!--
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit = "0:10"
if (document.images) {
var parselimit = limit.split(":")
parselimit = parselimit[0] * 60 + parselimit[1] * 1
}
function beginrefresh() {
if (!document.images)
return
if (parselimit == 1) {
window.document.forms[0].submit();
}
else {
parselimit -= 1
curmin = Math.floor(parselimit / 60)
cursec = parselimit % 60
if (curmin != 0)
curtime = curmin + " minutes and " + cursec + " seconds left until page refresh!"
else
curtime = cursec + " seconds left until page refresh!"
window.status = curtime
setTimeout("beginrefresh()", 1000)
}
}
window.onload = beginrefresh
//-->
</script>
这篇关于div在asp.net中自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文