ASP. NET small collection: Location object Introduction

Source: Internet
Author: User

Location object:
Location provides URL Information about the currently opened window or specific framework. A window object with multiple frames displays the URL of the parent window in the location attribute, and each frame also has a location object with it.

Hash attribute: Hash annotation is a good usage of a URL. It specifies the browser to a location located in the anchor of the document, which is equivalent to a bookmarks.

Host attribute: the host name and port used to describe the URL. Only when the port number is a specific part of the URL, the value includes the port number.

Hostname attribute: The Host Name of a typical URL is the name of the server on the network, which stores documents that can be viewed on your browser. For most web sites, server names include not only domain names, but also www prefixes. If the port number is specific in the URL, the host name is not included, but included in the host attribute.

Href attribute: This attribute provides a string of the entire URL of a specified window object.

Pathname attribute: the pathname part of a URL consists of directory structures related to the server root volume. The root is not part of the directory. If the URL path is a file to the root directory, the location. pathname attribute is (/).

Port attribute: the port number is rarely used. When you point to a URL of a site that has not been assigned a domain name, you can use location. port attribute to obtain the value. If you want to use a URL to create a URL, you must include the Server IP address and segment slogan. The IP address and segment slogan are separated.

Protocol attribute: Includes the Protocol name followed by a program.

Assign Method: Assign ("url") can be used to assign a new URL to the location object. Of course, you can also use direct value assignment or location. href to navigate to a new webpage. The assign method makes the code easy to maintain.

Reload method: This method can ignore all the document settings of the elements that the browser may save in the memory (in a record) and re-open the document, which is different from the refresh method on the browser. It works as if you selected the File menu open file. Of course, if you do not want to do this, there is a method similar to this method, that is, the history. Go () method.

Replace method: when a user jumps from the current webpage to another webpage, if you want to see the previous webpage without using the back button, you can use the location method. replace ("url") can implement this function

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.