看到別人的總結(jié),拿過(guò)來(lái)以后自己用,暫時(shí)先保存著
1)
<metahttp-equiv="refresh"content="10;url=跳轉(zhuǎn)的頁(yè)面">
10表示間隔10秒刷新一次
2)
<scriptlanguage=''javascript''>
window.location.reload(true);
</script>
如果是你要刷新某一個(gè)iframe就把window給換成frame的名字或ID號(hào)
3)
<scriptlanguage=''javascript''>
window.navigate("本頁(yè)面url");
</script>
4>
function abc()
{
window.location.href="/blog/window.location.href";
setTimeout("abc()",10000);
}
刷新本頁(yè):
Response.Write("<scriptlanguage=javascript>window.location.href=window.location.href;</script>")
刷新父頁(yè):
Response.Write("<scriptlanguage=javascript>opener.location.href=opener.location.href;</script>")
轉(zhuǎn)到指定頁(yè):
Response.Write("<scriptlanguage=javascript>window.location.href='yourpage.aspx';</script>")
刷新頁(yè)面實(shí)現(xiàn)方式總結(jié)(HTML,ASP,JS)
'by aloxy
定時(shí)刷新:
1,<script>setTimeout("location.href='url'",2000)</script>
說(shuō)明:url是要刷新的頁(yè)面URL地址
2000是等待時(shí)間=2秒,
2,<meta name="Refresh"content="n;url">
說(shuō)明:
n is the number of seconds to wait before loading the specifiedURL.
url is an absolute URL to be loaded.
n,是等待的時(shí)間,以秒為單位
url是要刷新的頁(yè)面URL地址
3,<%response.redirecturl%>
說(shuō)明:一般用一個(gè)url參數(shù)或者表單傳值判斷是否發(fā)生某個(gè)操作,然后利用response.redirect刷新。
4,刷新框架頁(yè)
〈scriptlanguage=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();</script〉
彈出窗體后再刷新的問(wèn)題
Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight:300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft:133px')</script>");//open
Response.Write("<script>document.location=document.location;</script>");
在子窗體頁(yè)面代碼head中加入<basetarget="_self"/>
刷新的內(nèi)容加在if (!IsPostBack) 中
在框架頁(yè)中右面刷新左面
//刷新框架頁(yè)左半部分
Response.Write("<scriptlanguage=javascript>");
Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");
Response.Write("</script>");
頁(yè)面定時(shí)刷新功能實(shí)現(xiàn)
有三種方法:
1,在html中設(shè)置:
<title>xxxxx</title>之後加入下面這一行即可!
定時(shí)刷新:<META HTTP-EQUIV="Refresh"content="10">
10代表刷新間隔,單位為秒
2.jsp
<% response.setHeader("refresh","1");%>
每一秒刷新一次
3.使用javascript:
<script language="javascript">
setTimeout("self.location.reload();",1000);
<script>
一秒一次
頁(yè)面自動(dòng)跳轉(zhuǎn):
1,在html中設(shè)置:
<title>xxxxx</title>之後加入下面這一行即可!
定時(shí)跳轉(zhuǎn)并刷新:<meta http-equiv="refresh"content="20;url=http://自己的URL">,
其中20指隔20秒后跳轉(zhuǎn)到http://自己的URL 頁(yè)面。
點(diǎn)擊按鈕提交表單后刷新上級(jí)窗口
A窗口打開(kāi)B窗口
然后在B里面提交數(shù)據(jù)至C窗口
最后要刷新A窗口
并且關(guān)閉B窗口
幾個(gè)javascript函數(shù)
//第一個(gè)自動(dòng)關(guān)閉窗口
<script language="javascript">
<!--
function clock(){i=i-1
document.title="本窗口將在"+i+"秒后自動(dòng)關(guān)閉!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=2
clock();
//-->
</script>
//第二個(gè)刷新父頁(yè)面的函數(shù)
<scriptlanguage="javascript">
opener.location.reload();
</script>
//第三個(gè)打開(kāi)窗口
<scriptlanguage="javascript">
function show(mylink,mytitle,width,height)
{mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')}
</script>
js刷新父頁(yè)面
非模態(tài)刷新父頁(yè)面:window.opener.location.reload();
模態(tài)刷新父頁(yè)面:window.dialogArguments.location.reload();
Response.Write("<scriptlanguage="javascript">rn");
Response.Write("<!--rn");
Response.Write("if(dialogArguments !=null){rn");
//注意上面的dialogArguments,就是父頁(yè)面showModalDialog()的第二個(gè)參數(shù)。
// 就是父頁(yè)面的window對(duì)象引用。
Response.Write("dialogArguments.location.reload(true);rn");
// 上面就是刷新父頁(yè)的代碼,相當(dāng)于在父頁(yè)上使用
// window.location.reload(true);代碼
Response.Write("window.close();}"); //關(guān)閉對(duì)話框
Response.Write("http://-->rn</script>");//關(guān)閉腳本塊
}
上面的代碼就是關(guān)閉對(duì)話框和刷新父頁(yè)的代碼,這段代碼也可以直接寫(xiě)入editdata.aspx的html中,然后在后臺(tái)cs中調(diào)用
<script>
<!--
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.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit`
if (curmin!=0)
curtime=curmin+"分"+cursec+"秒后重刷本頁(yè)!"
else
curtime=cursec+"秒后重刷本頁(yè)!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
file://-->
</script>
Javascript刷新頁(yè)面的幾種方法:
1history.go(0)
2location.reload()
3location=location
4location.assign(location)
5document.execCommand('Refresh')
6window.navigate(location)
7location.replace(location)
8document.URL=location.href
自動(dòng)刷新頁(yè)面的方法:
1.頁(yè)面自動(dòng)刷新:把如下代碼加入<head>區(qū)域中
<meta http-equiv="refresh"content="20">
其中20指每隔20秒刷新一次頁(yè)面.
2.頁(yè)面自動(dòng)跳轉(zhuǎn):把如下代碼加入<head>區(qū)域中
<meta http-equiv="refresh"content="20;url=http://點(diǎn)擊這里下載(然后在線播放)">
其中20指隔20秒后跳轉(zhuǎn)到http://點(diǎn)擊這里下載(然后在線播放)頁(yè)面
3.頁(yè)面自動(dòng)刷新js版
<scriptlanguage="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000);//指定1秒刷新一次
</script>
JS刷新框架的腳本語(yǔ)句
//如何刷新包含該框架的頁(yè)面用
<scriptlanguage=JavaScript>
parent.location.reload();
</script>
//子窗口刷新父窗口
<scriptlanguage=JavaScript>
self.opener.location.reload();
</script>
( 或 <ahref="javascript:opener.location.reload()">刷新</a>)
//如何刷新另一個(gè)框架的頁(yè)面用
<scriptlanguage=JavaScript>
parent.另一FrameID.location.reload();
</script>
如果想關(guān)閉窗口時(shí)刷新或者想開(kāi)窗時(shí)刷新的話,在<body>中調(diào)用以下語(yǔ)句即可。
<bodyonload="opener.location.reload()">開(kāi)窗時(shí)刷新
<bodyonUnload="opener.location.reload()">關(guān)閉時(shí)刷新
<scriptlanguage="javascript">
window.opener.document.location.reload()
[JS]讓頁(yè)面僅自動(dòng)刷新一次http://hi.baidu.com/lwlfree/blog/item/9a1ae024a41dd50b4c088ddd.html最近在做一個(gè)模塊,其中用到了選項(xiàng)卡。對(duì)比之后,決定使用JQuery的UI插件中的TAB功能。 雖然JQ的TAB有一個(gè)直接讀取頁(yè)面的功能,但是一般都是按照UTF-8編碼讀出的,因此想重用之前的頁(yè)面加載到TAB里就出現(xiàn)了大量的源碼。最后決定,讓TAB不直接讀取應(yīng)用頁(yè)面,僅讀取中轉(zhuǎn)頁(yè)面(中轉(zhuǎn)頁(yè)面中使用IFRAME來(lái)加載應(yīng)用頁(yè)面),從而達(dá)到切換TAB時(shí)動(dòng)態(tài)加載應(yīng)用頁(yè)面的功能。 然而使用IFRAME之后,發(fā)現(xiàn)要想使應(yīng)用頁(yè)面與TAB框架頁(yè)渾然一體的話,必須使IFRAME能夠自適應(yīng)應(yīng)用頁(yè)面的高度,雖然使用了JS來(lái)使IFRAME自適應(yīng)內(nèi)部頁(yè)面的高度,但是當(dāng)應(yīng)用頁(yè)面幾乎與框架同時(shí)加載完畢時(shí),還是無(wú)法自適應(yīng)IFRAME的高度,但是刷新IFRAME內(nèi)部的頁(yè)面時(shí),就可以自適應(yīng)高度。 由此想到讓頁(yè)面延時(shí)刷新的思路,但是僅使用setTimeout("window.location.reload();",500)來(lái)實(shí)現(xiàn)的時(shí)候,發(fā)現(xiàn)頁(yè)面會(huì)不停的刷,原因是:延時(shí)刷新之后,頁(yè)面重新加載setTimeout認(rèn)為還是第一次加載頁(yè)面,因而會(huì)不斷的刷新。 最后使用下面的代碼,解決了此問(wèn)題,代碼如下: functionreurl(){ url = location.href; //把當(dāng)前頁(yè)面的地址賦給變量 url var times = url.split("$"); //分切變量 url 分隔符號(hào)為 "$" if(times[1] != 1){ //如果$后的值不等于1表示沒(méi)有刷新 url += "&$1"; //把變量 url 的值加入 $1 self.location.replace(url); //刷新頁(yè)面 } window.onload =function () { setTimeout("reurl();",500) } 以上JS代碼可用于帶GET參數(shù)的URL。 注:我也沒(méi)有一個(gè)一個(gè)的測(cè)試,但是我用到的都是可以使用的,不過(guò)細(xì)節(jié)需要自己修改。 |
愛(ài)華網(wǎng)本文地址 » http://www.klfzs.com/a/25101016/320563.html
愛(ài)華網(wǎng)



