⑴ js怎麼寫2秒後再刷新當前頁面
設置定時2秒後執行刷新。
<script type="text/javascript">
setTimeout(function(){//使用setTimeout()方法設定定時2000毫秒
window.location.reload();/內/頁面容刷新
},2000);
</script>
(1)js定時器自動刷新擴展閱讀:
html代碼和JS代碼的區別
一、基礎不同
1、JS代碼:基於原型編程、多範式的動態腳本語言,並且支持面向對象、命令式和聲明式(如函數式編程)風格。
2、html代碼:是由HTML命令組成的描述性文本,HTML命令可以說明文字、圖形、動畫、聲音、表格、鏈接等。
二、用處不同
1、JS代碼:用於Web應用開發,常用來為網頁添加各式各樣的動態功能,為用戶提供更流暢美觀的瀏覽效果。
2、html代碼:結構包括頭部(Head)、主體(Body)兩大部分,其中頭部描述瀏覽器所需的信息,而主體則包含所要說明的具體內容。
⑵ 在PHP頁面上,怎麼用JS控制一個div裡面的數據在指定時間內自動刷新,有人會么。。。求助
如果只是純按照一定時間間隔刷新 最方便的使用這個
<meta http-equiv="refresh" content="刷新間隔的秒數;url=網址">
如果你版是想再某個事件被觸發權的情況下 刷新就用這個
location.reload() ;
或者
history.go(0) ;
刷新本頁其實就是重定向到本頁
所以也可以
location.href="網址";
如果你想用js代碼讓頁面自動刷新可以用定時執行的函數來實現
假設定時刷新的時間間隔是10秒 即 10000毫秒
手寫代碼:
<script>
function refresh()
{
location.reload() ;
}
setTimeout("refresh()",10000) ; //一旦計時到了10000毫秒就執行 refresh()函數
</script>
⑶ js 怎麼定時刷新指定頁面
將<metahttp-equiv=\\\"refresh\\\"content=\\\"20\\\">添加到head中,content=\\\"20\\\"指每隔20秒刷新一次頁面.
也可以用下面版的JS控制
<scriptlanguage=\\\"JavaScript\\\">
functionmyrefresh(){
window.location.reload();
}
setTimeout(\\\'myrefresh()\\\',1000);//指定權1秒刷新一次
</script>
或者是
functionrefresh()
{
window.location.href=\\\"當前頁面URL\\\";
setTimeout(\\\"refresh()\\\",10000);
}
⑷ js自動刷新
兩個div的顏色沒有不一致
reflesh死循環了(可能是你的疑問的罪魁禍首)
setTimeout("reflesh()",1000);//每10秒鍾刷新一次
這句話只執行了一次,而且1000=1秒
⑸ js自動刷新一個層的內容
//綁定並刷新
function fun() {
$.get("", { }, function (data) {
});
//3秒刷新方法
inti = self.setTimeout('fun();', 3000);
}
ajax 你懂的
⑹ 我想隔一會自動刷新一個網頁一下,用js定時器怎麼寫!
腳本寫不是更簡單
麻煩採納,謝謝!
⑺ js定時器怎麼使用
setInterval()循環執行相應的方法
<script type="text/javascript">
setInterval("myInterval()",1000);//1000為1秒鍾
function myInterval()
{
alert('實戰幫,javascript視頻課程');
}
</script>
1.setTimeout(Expression,DelayTime),在DelayTime過後,將執行一次Expression,setTimeout 運用在延遲一段時間,再進行某項操作。
setTimeout("",time) 設置一個超時對象
2.setInterval(expression,delayTime),每個DelayTime,都將執行Expression.常常可用於刷新表達式.
setInterval("",time) 設置一個超時對象
SetInterval為自動重復,setTimeout不會重復。
3.1clearTimeout(對象) 清除已設置的setTimeout對象
3.2clearInterval(對象) 清除已設置的setInterval對象
⑻ 如何用js 自動刷新 div 裡面的內容
用setInterval()方法來定時調用更新的方法來定時更新裡面的內容
⑼ JS,網頁定時刷新 , 例如等到 2017-3-12 8:30:00 自動刷新一次。
弄了兩小時 無語了 — _ —!!!!!!!!!!
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Language"content="zh-cn">
<metahttp-equiv="Content-Type"content="text/html;charset=GBK"/>
<title>網頁定時刷新</title>
<!--↓↓↓主函數↓↓↓-->
<script>
functioncsh(){
vardate=newDate();
varyear=date.getFullYear();
varmonth=date.getMonth()+1;
varday=date.getDate();
varhour=date.getHours();
varminute=date.getMinutes();
varsecond=date.getSeconds();
document.getElementById("year1").value=year;
document.getElementById("month1").value=month;
document.getElementById("day1").value=day;
document.getElementById("hour1").value=hour;
document.getElementById("minute1").value=minute;
document.getElementById("second1").value=second;}
//時鍾1子程序++++++++++++++++++++
functionClock1subroutine(i){
vardate=newDate();
varyear=date.getFullYear();
varmonth=date.getMonth()+1;
varday=date.getDate();
varhour=date.getHours();
varminute=date.getMinutes();
varsecond=date.getSeconds();
varA=0;
varB=0;
document.getElementById("year2").value=year;
document.getElementById("month2").value=month;
document.getElementById("day2").value=day;
document.getElementById("hour2").value=hour;
document.getElementById("minute2").value=minute;
document.getElementById("second2").value=second;
A=year-0+month-0+day-0+hour-0+minute-0+second;
B=(document.getElementById("year1").value-0)+
(document.getElementById("month1").value-0)+
(document.getElementById("day1").value-0)+
(document.getElementById("hour1").value-0)+
(document.getElementById("minute1").value-0)+
(document.getElementById("second1").value-0);
if(A==B){
location.reload();
}
setTimeout("Clock1subroutine("+i+")",1000);//延時後執行
}//時鍾1子程序----------
</script>
<!--↑↑↑主函數↑↑↑-->
</head>
<bodyonLoad="csh()">
刷新時間:
<inputid="year1"type="text"style="width:92px"/>年
<inputid="month1"type="text"style="width:92px"/>月
<inputid="day1"type="text"style="width:92px"/>日
<inputid="hour1"type="text"style="width:92px"/>時
<inputid="minute1"type="text"style="width:92px"/>分
<inputid="second1"type="text"style="width:92px"/>秒
<p/>
當前時間:
<inputid="year2"type="text"style="width:92px"/>年
<inputid="month2"type="text"style="width:92px"/>月
<inputid="day2"type="text"style="width:92px"/>日
<inputid="hour2"type="text"style="width:92px"/>時
<inputid="minute2"type="text"style="width:92px"/>分
<inputid="second2"type="text"style="width:92px"/>秒
<p/>
<inputtype="button"onclick="Clock1subroutine(0)"style="width:800px"value="開始"/>
<p/>
<iframesrc="http://www..com"width="800"height="600">
</body>
</html>