How do I put a hyperlink to "two levels above in the directory tree"?
I am trying to code my Home button. Is there a way to just climb back up the file structure, instead of using the absolute path like I have below.
I have a file index.html that I have at C:\Users\Randy\Documents\XML\
Heres my code:
<a id="my-family" href="C:\Users\Randy\Documents\XML\index.ht开发者_如何学JAVAml">Home</a>
Heres where I am trying to come from: C:\Users\Randy\Documents\XML\project\xml
to go two level up use "../../" and your normal url from two level up folder.
"../" in the path is used to go one level up. But, it can be used for more times, to go more levels up.
an example:
| HOME <br>
+- image.jpg<br>
|_
|
+- CONFIG<br>
|
+ PICTURE_CONFIG
|
+- myfile.html
myfile.html contains:
<img src="../../image.jpg" />
the second"../" goes from PICTURE_CONFIG to CONFIG folder
the first "../"goes from CONFIG to HOME folder
"image.jpg" searches in HOME folder for the file "image.jpg"
You can use ../index.html
to refer to index.html
in the parent directory.
On Windows OS, the forward-slash (/) wasn't working, so I switched to back-slash (\) and that fixed it. For example, try using the following:
"..\..\index.html"
I'm not sure exactly what you're asking, but in relative paths, ../
is 'up one level'.
So, ../index.html
would take you to the index of the next directory up. Hope that helps.
<img src="picture.jpg">
WHEN picture.jpg is located in the same folder as the current page<img src="images/picture.jpg">
WHEN picture.jpg is located in the images folder located in the current folder<img src="/images/picture.jpg">
WHEN picture.jpg is located in the images folder located at the root of the current web<img src="../picture.jpg">
WHEN picture.jpg is located in the folder one level up from the current folder<img src="../../picture.jpg">
WHEN picture.jpg is located in the folder two levels up from the current folder
Hope this example help :)
Source: https://www.w3schools.com/html/html_filepaths.asp
In IIS10 below is my observation and both works fine:
single Dot will take you one folder above
img src="./images/picture.jpg"
Double Dot will take you two folders above
img src="../images/picture.jpg"
精彩评论