Location. href user summary, location. href Summary

Source: Internet
Author: User

Location. href user summary, location. href Summary

*. 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.


What is the difference between toplocationhref and locationhref in javascript?

Top indicates the top-level window, that is, the window at the outermost layer. If several small windows are nested in a large window, using top in a small window Indicates the outermost large window.

How can I open the js statement locationhref in a new window?

Use window. open

Location. href can only direct the current page

Window. open ('opk: // Messages /? Uid = 0 & target = '+ s_price );

Isn't that a problem with spear and shield. It is a pain between pop-up and interception.
After checking, there is a way to avoid being intercepted, but it is too complicated. You can use a compromise to prompt

Var win = window. open ('opk: // Messages /? Uid = 0 & target = '+ s_price );
If (win = null ){
Alert ('the new window looks blocked by a pop-up window blocker. If you want to open a new window, we recommend that you add the site to the allowed pop-up list set by the interception program. Some pop-up blocking programs allow you to open a new window when you press Ctrl. ');
}

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.