Location. href user Summary

Source: Internet
Author: User

*. Location. href usage:
Top. Location. href = "url" opens the URL on the top-level page (jump out of the Framework)
Self. Location. href = "url" only opens the URL address on this page
Parent. Location. href = "url" opens the URL address in the parent window.
This. Location. href = "url" is used in the same way as self.
If (top. Location = self. Location) determines whether the current location is the top layer to prohibit frame reference.
If a custom frame exists on the page, you can replace parent self top with the name of the custom frame.
The effect is to open the URL address in the custom frame window.
 
Javascript frame refresh
Reference:
--------------------------------------------------------------------------------

This is a simple example:
Top.htm code
<Script language = JavaScript>
Function RS (){
Parent. Left. Location. href = "top.htm"
Parent. Bot. Location. href = "top.htm"
}
</SCRIPT>
<Input type = button name = Name value = "ksdj" onclick = RS ();>

The following is an HTM file with a random File Name:
<Frameset Cols = "150, *">
<Frame src = "left.htm" name = left>
<Frameset rows = "150, *">
<Frame src = "top.htm" name = top>
<Frame src = "bot.htm" name = bot>
</Frameset>
</Frameset>
Try it by yourself. I think you may want this effect!

--------------------------------------------------------------------------------


I quoted the reply from my old man upstairs. Could you explain it.
Top.htm code
<Script language = JavaScript>
Function RS (){
Parent. left. location. href = "top.htm" // partentrefers to the parent page and the most external framework page. leftmust be left.htm, location is the object of the Left page, and href is an attribute of the location object, which determines the left URL address. So here we will give the address you need To this parent. Left.
Parent. Bot. Location. href = "top.htm" // the meaning of this sentence is roughly the same as above.
} // When the function ends, two URLs are updated at the same time!
</SCRIPT>
<Input type = button name = Name value = "ksdj" onclick = RS ();>

The following is an HTM file with a random File Name:
<Frameset Cols = "150, *">
<Frame src = "left.htm" name = left> // defines a name for this left.htm: left
<Frameset rows = "150, *">
<Frame src = "top.htm" name = top> // defines the top.htm name as top.
<Frame src = "bot.htm" name = bot> // defines a bot name for this bot.htm.
</Frameset>
</Frameset>

The location attribute of the window object contains the address (URL) information of the current page. You can directly change this attribute value and set it to a new address (URL ):

Window. Location = "http://www.yahoo.com /";
Or
Location = "http://www.yahoo.com /";

You can also use either of the following two methods to make the Browser Download The (load) page from the server:

Reload ()-prompts the browser to download the current page again, that is, "refresh" the current page.
Replace (URL)-prompt the browser to download the Page Based on the address (URL) given in the URL parameter, and store the historical records in the current browser (that is, the list of browsed pages) to overwrite the current page.
Using the Replace () method means that the user will not be able to return to the previous page by pressing the "return" button, but this does not mean that the user cannot return to all the original pages at all, they just cannot return to the page replaced by the Replace () method (Note: Only the page replaced ).

Framedemo.html,top.html,button.html is used as an example to describe how to do this.

In this example, framedemo.html consists of two pages:

<Frameset rows = "50%, 50%"> <frame name = Top src = "top.html"> <frame name = button src = "button.html"> </frameset>

Now, let's set the top.html, that is, there is a button on the above page to refresh the following page. You can use the following seven statements.

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

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.

 
I have read some articles to my summary:
Top. Location is to open a new page in the top frame.
Window. Location is to open a new page in the current frame.
Parent. Location opens the URL address in the parent window of the current window.

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.