SRC directory file Reference path before adding "/" and does not add "/" there is a difference

Source: Internet
Author: User
Tags file info parent directory
JS file path before adding "/" and do not add "/" There is a difference, please ask why. For example:
<script type= "Text/javascript" src= "/js/ibanner.js" ></script>
<script type= "Text/javascript" src= "Js/ibanner.js" ></script>

Plus "/" is to represent the absolute path, without "/" is to represent the relative path.

Here's an example to illustrate absolute and relative paths

Absolute path:

Assume that there is a domain name www.xxx.com, and the application of the virtual host, the virtual host has a directory, such as WWW, this www is the root directory of the site.

The root directory is decentralized with a file index.html, the absolute path of this file is: http://www.xxx.com/index.html.

Suppose a directory called function is built in the WWW root directory, and then a file info.html is placed in the directory, and the absolute path to the file is http://www.xxx.com/function/info.html.

Relative path

Suppose: The info.html path is: d:/web/www/function/info.html

The index.html path is: d:/web/www/index.html

Writing: <a href = "index.html" > This is a super join </a>

Parent Directory

.. /indicates the directory in which the source file resides

Suppose: The info.html path is: d:/web/www/function/info.html

The index.html path is: d:/web/www/index.html

Writing: <a href = ". /index.html "> This is a super connection </a>

Upper Parent Directory

Suppose: The info.html path is: d:/web/www/function/inc/info.html

The index.html path is: d:/web/www/index.html

Writing: <a href = ". /function/inc/info.html ">info.html</a>

Subordinate Directory

A file that refers to a subordinate directory, directly to the path of the subordinate directory file.

Suppose: The info.html path is: d:/web/www/function/info.html

The index.html path is: d:/web/www/index.html

Writing: <a href = "html/info.html" > This is a hyper-connection </a>.

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.