很简单的知识点,作为个人笔记记下来。
[1]绝对路径:完整链接地址 eg.http://www.xxx.com/common/js/demo.js
[2]相对路径:相对路径有两种情况,有'/'开头与没有'/'开头
(1)、有'/'开头,相对域名
eg. url: http://www.xxx.com/test/ js地址:/common/js/demo.js 实际加载js地址:http://www.xxx.com/common/js/demo.js
(2)、没'/'开头,相对当前路径[址栏的路径]
eg.url: http://www.xxx.com/test/ js地址:common/js/demo.js 实际加载js地址:http://www.xxx.com/test/common/js/demo.js
[3]如果在html->head中使用base标签,则页面上没有'/'开头的相对路径参照base标签给的路径,不再参照地址栏的路径
eg.<base href="http://www.xxx.com/base/" /> 站点url:http://www.xxx.com/test/ js地址:common/js/demo.js 实际加载js地址:http://www.xxx.com/base/common/js/demo.js