Javascript refresh framework and PAGE method set

Source: Internet
Author: User
Statement:
Recently, more and more people feel the superiority of JS. The method for refreshing the framework page is used in the project, and many good results are found after searching on the Internet. Code , But not very complete. As a result, I simply collected data from the network and sorted it out after careful arrangement. ^-^ Hope you can give me more advice!

Let's look at a simple example:
The following example uses the three pages separated by frame.html?top.html?bottom.html to describe how to do this.

Frame.html consists of two pages (bottom (bottom.html) under the top (top.html#). The Code is as follows: <! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en" >
< Html >
< Head >
< Title > Frame </ Title >
</ Head >  
< Frameset Rows = "50%, 50%" >
< Frame Name = Top SRC = "Top.html" >
< Frame Name = Bottom SRC = "Bottom.html" >
</ Frameset >
</ Html >

Now, let's assume that top.html (the page above) has seven buttoners to refresh bottom.html (the page below). You can use the following seven statements to see which one is easy to use.

Statement 1. Window. Parent. Frames [1]. Location. Reload ();
Statement 2. Window. Parent. frames. Bottom. Location. Reload ();
Statement 3. Window. Parent. Frames ["bottom"]. Location. Reload ();
Statement 4. Window. Parent. frames. Item (1). Location. Reload ();
Statement 5. Window. Parent. frames. Item ('bottom '). Location. Reload ();
Statement 6. Window. Parent. Bottom. Location. Reload ();
Statement 7. Window. Parent ['bottom ']. Location. Reload ();

The code for the top.html page is as follows:

<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en" >
< Html >
  < Head >
< Title > Top.html </ Title >
  </ Head >
< Body >
< Input Type = Button Value = "Refresh 1" Onclick = "Window. Parent. Frames [1]. Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 2" Onclick = "Window. Parent. frames. Bottom. Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 3" Onclick = "Window. Parent. Frames ['bottom ']. Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 4" Onclick = "Window. Parent. frames. Item (1). Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 5" Onclick = "Window. Parent. frames. Item ('bottom '). Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 6" Onclick = "Window. Parent. Bottom. Location. Reload ()" > < BR >
< Input Type = Button Value = "Refresh 7" Onclick = "Window. Parent ['bottom ']. Location. Reload ()" > < BR >
</ Body >
</ Html >

Below is the bottom.html pageSource codeTo verify that the page below is refreshed, a dialog box is displayed after loading.

The code for the bottom.html page is as follows: <! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en" >
< Html >
  < Head >
< Title > Bottom.html </ Title >
  </ Head >
< Body Onload = "Alert ('I got loaded! ')" >
< H1 > This is the content in bottom.html. </ H1 >
</ Body >
</ Html >

Explanations:
1. windowless refers to the front page. For example, this refers to the top.html page.
2. Parent refers to the parent page of the current page, that is, the framework page containing it. In this example, framedemo.html is used.
3. frames is a window object and an array. Represents all the child pages in the framework.
4. item is a method. Returns the elements in the array.
5. If the sub-page is also a framework page and contains other sub-pages, some of the above methods may not work.

Appendix:
How to refresh the page with javascript:
1 history. Go (0)
2 location. Reload ()
3 location = Location
4 location. Assign (location)
5 document.exe ccommand ('refresh ')
6 window. navigate (location)
7 location. Replace (location)
8 Document. url = location. href

How to automatically refresh the page:
1. Automatically refresh the page: Add the following code to the <Meta http-equiv = "refresh" content = "20">
20 indicates refreshing the page every 20 seconds.

2. automatic page Jump: Add the following code to the <Meta http-equiv = "refresh" content = "20; url = http://www.wyxg.com">
20 means jump to the http://www.wyxg.com page every 20 seconds

3. Automatically refresh JS version on the page
<Script language = "JavaScript">
Function myrefresh ()
{
Window. Location. Reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</SCRIPT>

How does ASP. net output the script statement for refreshing the parent window?
1. This. response. Write ("<SCRIPT> opener. Location. Reload (); </SCRIPT> ");

2. This. response. Write ("<SCRIPT> opener. Window. Location. href = opener. Window. Location. href; </SCRIPT> ");

3. response. Write ("<script language = JavaScript> opener. Window. navigate (''page you want to refresh. asp''); </SCRIPT> ")


JS refresh framework script statement

// How to refresh the page containing the framework
<Script language = JavaScript>
Parent. Location. Reload ();
</SCRIPT>

// Refresh the parent window in the Child Window
<Script language = JavaScript>
Self. opener. Location. Reload ();
</SCRIPT>
(Or<A href = "javascript: opener. Location. Reload ()">Refresh</A>)

// How to refresh the page of another framework
<Script language = JavaScript>
Parent. Another frameid. Location. Reload ();
</SCRIPT>

If you want to refresh the window when closing or when you want to open the window<Body>.

<Body onload = "opener. Location. Reload ()">Refresh when opening window
<Body onUnload = "opener. Location. Reload ()">Refresh when disabled

<Script language = "JavaScript">
Zookeeper opener.doc ument. Location. Reload ()
</SCRIPT>
Http://www.cnblogs.com/xugang/archive/2007/10/10/919794.html

Related Article

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.