Common page Refresh Code

Source: Internet
Author: User

Common page Refresh Code
Here is a collection of ASP tutorials. NET page Refresh method and JS page refresh code, hope that interested friends can try.
First:

private void Button1_Click (object sender, System.EventArgs e)
{
Response.Redirect (Request.Url.ToString ());
}


Second:

private void Button2_Click (object sender, System.EventArgs e)
{
Response.Write ("
<script language= Web page special effects >window.location.href=document. URL;
</script> ");
}

Third:

private void Button3_Click (object sender, System.EventArgs e)
{
Response.AddHeader ("Refresh", "0");
}


Fourth:

private void Button6_click (object sender, System.EventArgs e)
{
Like something's wrong?
Response.Write ("
<script language=javascript>window.location.reload ();
</script> ");
}


V: (need to replace <>)

<script><!--
var limit= "3:00"
if (document.images)
{
var parselimit=limit.split (":") parselimit=parselimit[0]*60+parselimit[1]*1
}
function Beginrefresh ()
{
if (!document.images) returnif (parselimit==1) window.location.reload () Else
{
Parselimit-=1curmin=math.floor (PARSELIMIT/60) cursec=parselimit%60if (curmin!=0) curtime=curmin+ "cent" +cursec+ " Second, brush this page again! "elsecurtime=cursec+" seconds after the brush this page! "Window.status=curtimesettimeout (" Beginrefresh () ", 1000)
}
}
window.onload=beginrefresh//--> </script><div style= "z-index:102;
left:408px;
Position:absolute;
top:232px "ms_positioning=" text2d ">
<p><font size= "3" > Auto Refresh page </FONT></P>
</DIV> Sixth:
<meta http-equiv= "Refresh" content= "300;
Url=target.html ">

Refresh another frames page with the WINDOW.LOCATION.HREF implementation
In writing ASP.net program, we often encounter the problem of the jump page, we often use Response.Redirect, if the customer wants to jump in the use of tips, this is not a good idea, such as:

Response.Write ("Congratulations to you, registered success!") <script>alert ');</script> ");
Response.Redirect ("Http://www.111cn.net");

At this time our prompt content did not come out on the jump, and Response.Redirect ("main.html");

Then we use the following code to test:

Response.Write ("<script Language=javascript>alert") (' Congratulations, registration success! ') </script> ");
Response.Write ("<script language=javascript>window.location.href= ' main.html ' </script>");

This is the realization of our requirements, in the prompt after the jump page.

The most important thing is that the WINDOW.LOCATION.HREF statement can implement a frame of the page after executing the server-side code to refresh another frame of the page (Response.Redirect cannot be reached, at least I did not find):

For example, there are two frames in the index.htm page, Frameleft and Frameright, which refresh the page in the Frameleft after the server-side code is executed on the Frameright page.

Before the most common is registered, automatically refresh the landing box, so that the landing box into the landing page, as long as the registration of successful code after the addition of a paragraph, that can be implemented to refresh another frame of the page. The code is as follows:

Response.Write ("<script Language=javascript>alert") (' Congratulations, registration success! ') </script> ");
Response.Write ("<script language=javascript>window.parent.frameleft.location.href= ' main.html ' </script > ");

Summary of implementation methods for automatically refreshing pages:

1)
<meta http-equiv= "Refresh" content= "10;url= jump page" >
10 indicates a refresh interval of 10 seconds
2)
<script language= ' JavaScript ' >
Window.location.reload (TRUE);
</script>
If you want to refresh an iframe, replace the window with the name or ID number of the frame.
3)
<script language= ' JavaScript ' >
Window.navigate ("This page URL");
</script>
4>

Function ABC ()
{
Window.location.href= "/blog/window.location.href";
SetTimeout ("ABC ()", 10000);
}

Refresh this page:
Response.Write ("<script language=javascript>window.location.href=window.location.href;</script>")

Refresh Parent page:
Response.Write ("<script language=javascript>opener.location.href=opener.location.href;</script>")

Go to the specified page:
Response.Write ("<script language=javascript>window.location.href= ' yourpage.aspx ';</script>")


Refresh page Implementation Summary (HTML,ASP,JS)
' By Aloxy

Timed refresh:
1,<script>settimeout ("location.href= ' url '", Watts) </script>

Description: URL is the page URL address to refresh
2000 is the wait time = 2 seconds,

2

, <meta name= "Refresh" content= "N;url" >

Description
n is the number of seconds to wait before loading the specified URL.
URL is a absolute URL to be loaded.
N, is the time to wait, in seconds
URL is the URL address of the page to be refreshed

3,<%response.redirect url%>

Note: Generally use a URL parameter or table conveys value to determine whether an operation occurred, and then use Response.Redirect refresh.

4, refresh the frames page

〈script language=javascript>top.leftfrm.location.reload ();p arent.frmTop.location.reload (); </script〉

Problems when you pop up a form and then refresh it

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>");

In the subform page code head, add <base target= "_self"/>

The refreshed content is added to the IF (! IsPostBack) in

Flush the left side of the frame page
Refresh the left half of the frames page

Response.Write ("<script language=javascript>");
Response.Write ("parent.left.location.href= ' paydetailmanage_left.aspx '");
Response.Write ("</script>");


Page timed Refresh function implementation

There are three different ways:
1, set in HTML:
After <title>xxxxx</title> join the following line!
Timed Refresh

: <meta http-equiv= "Refresh" content= "ten" >


10 represents the refresh interval, in seconds

2.jsp Tutorials

<% response.setheader ("Refresh", "1");%>


Refresh once per second

3. Use javascript:

<script language= "JavaScript" >
SetTimeout ("Self.location.reload ();", 1000);
<script>


Once a second


Page Auto Jump:
1, set in HTML:
After <title>xxxxx</title> join the following line!

timed Jump and refresh: <meta http-equiv= "Refresh" content= "20;url=http://own url" ",


20 of which refers to 20 seconds after the jump to http://own url page.


Click the button to submit the form and refresh the parent window

A window opens the b window

And then submit the data to the C window in B.

Last to refresh window a

and close the b window

Several JavaScript functions

First Auto Close window

<script language= "JavaScript" >
<!--
function Clock () {i=i-1
document.title= "This window will be automatically closed after" +i+ "seconds!";
if (i>0) settimeout ("clock ();", 1000);
else Self.close ();}
var i=2
Clock ();
-->
</script>

A second refresh

Function of Parent page

<script language= "JavaScript" >
Opener.location.reload ();
</script>


The third opens a window

<script language= "JavaScript" >
Function Show (mylink,mytitle,width,height)
{Mailwin=window.open (mylink,mytitle, ' top=350,left=460,width= ' +width+ ', height= ' +height+ ', Scrollbars=no ')}
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.