JS Refresh page sum! A variety of JS Refresh page code!

Source: Internet
Author: User

1)
<meta http-equiv= "Refresh" content= "10;url= jump page" >
10 indicates a 10-second interval refresh
2)
<script language= ' JavaScript ' >
Window.location.reload (TRUE);
</script>
If you want to refresh an iframe, change the window to a frame name or ID number.
3)
<script language= ' JavaScript ' >
Window.navigate ("URL of this page");
</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 '", ",") </script>

Description: URL is the URL address of the page to be refreshed
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.
The URL is a absolute URL to being loaded.
N, is the time to wait, in seconds
URL is the URL address of the page to refresh

3,<%response.redirect url%>

Description: Generally use a URL parameter or table only son value to determine whether an action occurred, and then use Response.Redirect refresh.

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

Issues that pop up after the form is refreshed


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

Refresh the left side of the frame page
Refresh the left half of the frame page
Response.Write ("<script language=javascript>");
Response.Write ("parent.left.location.href= ' paydetailmanage_left.aspx '");
Response.Write ("</script>");


Page Timing Refresh Feature implementation

There are three ways to do this:
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
<% response.setheader ("Refresh", "1"); %>
Refresh every second

3. Using 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 means 20 seconds after the jump to http://its own URL page.


Refresh the parent window after clicking the button to submit the form

A window opens b window

Then submit the data in B to the C window.

Finally, to refresh the A window

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 automatically turn off after" +i+ "seconds!";
if (i>0) setTimeout ("clock ();", 1000);
else Self.close ();}
var i=2
Clock ();
-
</script>

Second function to refresh the parent page

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


Third Open 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>

JS Refresh parent Page

Non-modal Refresh parent page: Window.opener.location.reload ();
Modal Refresh parent page: Window.dialogArguments.location.reload ();

Response.Write ("<script language=\" javascript\ ">\r\n");
Response.Write ("<!--\ r \ n");
Response.Write ("if (dialogarguments! = null) {\ r \ n");
Notice the dialogarguments above, which is the second parameter of the parent page ShowModalDialog ().
is the Window object reference of the parent page.
Response.Write ("DialogArguments.location.reload (true); \ r \ n");
This is the code that refreshes the parent page, which is equivalent to using the
Window.location.reload (true); code
Response.Write ("Window.close ();}"); Close the dialog box
Response.Write ("//-->\r\n</script>"); Close script block
}
The code above is to close the dialog box and refresh the code of the parent page, which can also be written directly into the editdata.aspx HTML and then called in the background CS

<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%60
if (curmin!=0)
curtime=curmin+ "+cursec+" seconds to re-brush this page! "
Else
curtime=cursec+ "re-swipe this page after seconds! "
Window.status=curtime
SetTimeout ("Beginrefresh ()", 1000)
}
}

Window.onload=beginrefresh
File://-->
</script>

JavaScript refreshes the page in several ways:

1 history.go (0)

2 Location.reload ()

3 location=location

4 Location.assign (location)

5 Document.execcommand (' Refresh ')

6 Window.navigate (location)

7 Location.replace (location)

8 document. Url=location.href

Ways to automatically refresh pages:

1. Automatic page refresh: Add the following code to the

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

20 refers to a refresh of the page every 20 seconds.

2. Page Auto-jump: Add the following code to the

<meta http-equiv= "Refresh" content= "20;url=http://www.wyxg.com" >

Where 20 means jump to http://www.wyxg.com page after 20 seconds

3. Page automatically refresh JS version

<script language= "JavaScript" >

function Myrefresh ()

{

Window.location.reload ();

}

SetTimeout (' Myrefresh () ', 1000); Specify 1 seconds to refresh

</script>

JS Refresh Framework Script statement

How to refresh the page that contains the frame

<script language=javascript>

Parent.location.reload ();

</script>

child window refreshes parent window

<script language=javascript>

Self.opener.location.reload ();

</script>

(or <a href= "javascript:opener.location.reload ()" > Refresh </a>)

How to refresh another frame's page with

<script language=javascript>

Parent. Another FrameID.location.reload ();

</script>

Call the following statement in <body> if you want to refresh the window or refresh it when you want to open it.

<body onload= "Opener.location.reload ()" > Windows Refresh

<body onunload= "Opener.location.reload ()" > Refresh when off

<script language= "JavaScript" >

Window.opener.document.location.reload ()

[JS] Let the page only automatically refresh once http://hi.baidu.com/lwlfree/blog/item/9a1ae024a41dd50b4c088ddd.html

Recently a module was being made, which used the tab. After comparison, you decide to use the tab feature in JQuery's UI plug-in.

Although JQ tab has a direct Read page function, but is generally read according to UTF-8 encoding, so want to reuse before the page loaded into the tab has a lot of source code. Finally, the tab is not read directly to the application page, only the transit page (using an IFRAME in the relay page to load the application page), so that the ability to dynamically load the application page when switching tab.

However, after using the IFRAME, it is found that in order to make the application Page and tab frame page seamless, the IFRAME must be able to adapt to the height of the application page, although JS is used to adapt the IFRAME to the internal page height, but when the application page is almost loaded with the frame at the same time, The height of the IFRAME is still not adaptive, but when you refresh the page inside the IFRAME, you can adapt the height.

The idea of allowing the page to refresh, but only using settimeout ("window.location.reload ();", 500) to achieve the time, found that the page will continue to brush, the reason is: after the delay refresh, Page Reload settimeout think it is the first time to load the page, so it will continue to refresh.

Finally, the following code is used to solve this problem, the code is as follows:

function Reurl () {

url = location.href; Assigns the address of the current page to the variable URL

var times = Url.split ("$"); The split variable URL separator symbol is "$"

if (times[1]! = 1) {//If the value after $ is not equal to 1 means no refresh

URL + = "&$1"; Add the value of the variable URL to

Self.location.replace (URL); Refresh Page

}
}

Window.onload = function () {setTimeout ("reurl ();", 500)}

The above JS code can be used for URLs with get parameters.

JS Refresh page sum! A variety of JS Refresh page code!

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.