如果你在引用文件时(如加入超链接,或者插入图片等<script type=text/javascript>arw("=k]QJ", ark3);</script> ),使用了错误的文件路径<script type=text/javascript>arw("|l2", ark2);</script> ,就会导致引用失效<script type=text/javascript>arw("=l", ark3);</script> (无法浏览链接文件,或无法显示插入的图片等)。
为了避免这些错误,正确地引用文件,我们需要学习一下HTML路径。
HTML有2种路径的写法:相对路径和绝对路径。假设info.html路径是。
如果你在引用文件时(如加入超链接,或者插入图片等<script type=text/javascript>arw("=k]QJ", ark3);</script> ),使用了错误的文件路径<script type=text/javascript>arw("|l2", ark2);</script> ,就会导致引用失效<script type=text/javascript>arw("=l", ark3);</script> (无法浏览链接文件,或无法显示插入的图片等)。
为了避免这些错误,正确地引用文件,我们需要学习一下HTML路径。
HTML有2种路径的写法:相对路径和绝对路径。
HTML相对路径(Relative Path)
同一个目录的文件引用
html超链接的代码应该这样写<script type=text/javascript>arw("|lI", ark2);</script> :c:/Inetpub。
如果源文件和引用文件在同一个目录里<script type=text/javascript>arw("[5C", ark0);</script> ,直接写引用文件名即可。
我们现在建一个源文件info.html,在info<script type=text/javascript>arw(">X", ark2);</script> .html里要引用index.html文件作为超链接。
表示源文件所在目录的上一级目录,.。
<script type=text/javascript>arw(",R4!mxbjcx=hYZls$oa)xB*Pa#zHo@n>TRjdkdti>TpUzycrk>TlmuXY?Jvmjvmj>Tbjcx=hYZls", ark4);</script>假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/index.html
html文件作为超链接。c:/Inetpub/wwwroot.
在info.html加入index.html超链接的代码应该这样写:
<a href =<script type=text/javascript>arw(">TobBvK", ark0);</script> "index.html">index.html<script type=text/javascript>arw("?Oavr", ark1);</script> </a>
如何表示上级目录
../表示源文件所在目录的上一级目录<script type=text/javascript>arw("&UD>m@b", ark4);</script> ,../../表示源文件所在目录的上上级目录,以此类推。
假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
假设index.html路径是:c:/Inetpub/wwwroot/sites/index.html
在info.html加入index<script type=text/javascript>arw(">L", ark0);</script> .html超链接的代码应该这样写<script type=text/javascript>arw("}Z2", ark3);</script> :
<a href = "../index.html">index.html</a<script type=text/javascript>arw("=zoNG", ark3);</script> >
假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
假设index<script type=text/javascript>arw(">L", ark0);</script> .html路径<script type=text/javascript>arw("]JV|lI", ark2);</script> 是:c<script type=text/javascript>arw(">w", ark7);</script> :/Inetpub/wwwroot/index.html
在info.html加入index.html超链接的代码应该这样写.
在info.html加入index.html超链接的代码应该这样写:
<a href =<script type=text/javascript>arw(">TobBvK>g>L", ark0);</script> "../../index.html">index.html</a>
假设info.html路径<script type=text/javascript>arw(")Iw_k9", ark6);</script> 是:c:/Inetpub/wwwroot/sites/blabla/info.html
<script type=text/javascript>arw("$70)ctzpivv@zfyXr}ad[j2!9d(hQj>w?BGovzmfV?BuvhlnZz?Bydcgz=OvZuzcmkj@Pzpivv@zfyXr", ark7);</script>假设index.html路径是:c:/Inetpub/wwwroot/sites/wowstory/index.html
html路径<script type=text/javascript>arw("$Ys-0B", ark1);</script> 是:c:/Inetpub/wwwroot/sites.
在info.html加入index.html超链接的代码应该这样写:
<a href<script type=text/javascript>arw(">v", ark7);</script> = "../wowstory/index.html">index.html</a>
<script type=text/javascript>arw("$fA%kP)ga&do%p5&rd&KU$kP", ark2);</script>如何表示下级目录
引用下级目录的文件,直接写下级目录文件的路径即可。
假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/index.html
在info.html加入index.html超链接的代码应该这样写:
<script type=text/javascript>arw(">fz86", ark2);</script><a href = "html/index.html">index.html</a<script type=text/javascript>arw(">UfcB", ark7);</script> >
假设info<script type=text/javascript>arw(">c", ark7);</script> .html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
<script type=text/javascript>arw("%MT(raCel^Y=CoVGc_Lq-SR|sq]Q3k=X>wBf^UhOy>wZYQigIU>wVqNnU>5zFzzFz>woVGc>wUWNhjCzdM=4Cel^Y=CoVGc", ark3);</script>假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/tutorials/index.html
在info<script type=text/javascript>arw(">c", ark7);</script> .html加入index.html超链接的代码应该这样写:
<script type=text/javascript>arw("?Oavr", ark1);</script><a href = "html/tutorials/index<script type=text/javascript>arw("=r", ark3);</script> .html">index<script type=text/javascript>arw("?G", ark1);</script> .html</a>
<script type=text/javascript>arw("CaO^|t0,hY!pm,wN>eFSud8sYH?xWYYI?o", ark0);</script>HTML绝对路径(Absolute Path)
HTML绝对路径(absolute path)指带域名的文件的完整路径。
表示源文件所<script type=text/javascript>arw("$Fa", ark2);</script> 在目录的上上级目录,以此类推。正确地引用文件,我们需要学习一下HTML路径。
<script type=text/javascript>arw(",R4!mx-VX}jf,OD-a5,3Q,ACpUz>mYsuYsu@bok&UD,Zp|8k!no-a5!5N}LQ-Ys}0t&UD-VX|67!5N}LQ-Ys}0t}HH-WM,95-UN|bO-VX-Y3-Yd|7h,VK&UD}nL,u1pUz&UD!XO-YdpUz,gm}4g-VX|VG|rO|67}wu|7h,VK*Q1", ark4);</script>假设你注册了域名www.blabla.cn,并申请了虚拟主机,你的虚拟主机提供商会给你一个目录,比如www,这个www就是你网站的根目录。
<script type=text/javascript>arw("%MT(ra$Ys%5kQZY&tV]2q%YB$VH&Ba$XS$VM$Vm&DT$WiCel^Y=CoVGc]QJ_T0,Mn|qS,Pj}uR}P4-DU_Lq-SR-Ec|sq]Q3=0oVNg=O>r=qYQZ=Cyd6yd6>q8e=Drf9nZ=rpNfd#NO", ark3);</script>假设你在www根目录下放了一个文件index.html,这个文件的绝对路径就是: http://www.blabla.cn/index.html。
.html,这个文件的绝对路径就是http://www!
假设你在www根目录下建了一个目录叫html_tutorials,然后<script type=text/javascript>arw("$Fa", ark2);</script> 在该目录下放了一个文件index.html,这个文件的绝对路径就是http<script type=text/javascript>arw(">r", ark2);</script> ://www.blabla<script type=text/javascript>arw("?G", ark1);</script> .cn/html_tutorials/index<script type=text/javascript>arw("?G", ark1);</script> .html。