How does the browser generate a URL?

Source: Internet
Author: User

How does the browser generate a URL?

Click the link on the page and the browser will perform different processing based on the relative URL path in the source code:

(1) There is a protocol name, but there is no Domain Name Information

For a URL in this form, its Protocol, path, query string, and fragment ID are subject to its own, but the part of the domain name information is subject to the page address that references it.

(2) No protocol name, But Domain Name Information

The protocol name is determined by the original launch page, and all subsequent URL information is taken from this relative URL to form a complete URL.

(3) No protocol name, no domain name information, but path

If the base tag is explicitly provided on the webpage, the obtained URL is base URL + path.

If no base tag is provided, there are two results:

A) if the relative URL starts with a slash (root directory), the URL Information of the current page is ignored and the relative path is directly placed behind the Domain Name of the current page.

B) if the start of the relative URL is not a slash, the last/suffix content of the current page URL will be removed, and the remaining content will be returned as the base URL, and the relative path will be spliced after it.

(4) No protocol name, domain name information, no path, but query string

The Protocol, domain name, and path information are all copied from the original referenced URL, and the query string and fragment ID are from the relative URL.

(5) Only fragment

Only fragment is replaced. All other information is copied from the original referenced URL.

<Base> tag

The browser extracts the corresponding part from the UR of the current page to fill in the blank space in the relative URL. You can use the <base> label to change the value. The browser will no longer use the URL of the current document, but will use the specified basic URL to parse all relative URLs. These include the URLs in the <a>, , <link>, and <form> labels.

The browser also adjusts the URL of the current page and generates a new request URL in the address bar.

 

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.