Why are some of my HTML internal links working and others not?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 03:51:47

问题


Help, I am totally new to this world.

I am making a menu bar on front page to with links to other pages on the site, here is example of code:

<ul id="menu">
<li><a href="file:///Users/tamborine/Downloads/about_page.htm">About</a></li>
<li><a href=“file:///Users/tamborine/Downloads/the_therapist_page.html”>The Therapist</a></li>
<li><a href=“file:///Users/tamborine/Downloads/pay_what_you_can_page.htm”>Pay what you can</a></li>
<li><a href=“file:///Users/tamborine/Downloads/projects_we_support_page.htm”>Projects we support</a></li>
<li><a href=“file:///Users/tamborine/Downloads/resources_page”>Resources</a></li>
<li><a href=“file:///Users/tamborine/Downloads/prices_page”>Prices</a></li>
<li><a href=“file:///Users/tamborine/Downloads/faq_page.htm”>FAQ</a></li>
</ul>

When I open in browser only the first link (About) works, the others show 'File not Found' in browser

I've been searching forums and inspect element shows strange characters not present in html. I'm thinking encoding error? I am using TextEdit on mac. I tried playing with TextEdit settings, file format is plain text, encoding tried with UTF-8 and ASCII but no change.

I was previously on another computer using notepad and internet explorer when I made the first page (About) that is the only link that actually works now. Now I'm on mac, with TextEdit and Firefox.

Ideas? Thank you kindly


回答1:


You have smart quotes in all but the first link. Those smart quotes are considered part of the URL which causes the browser to resolve your URLs incorrectly.

Make sure that OS X isn't automatically converting your double quotes into smart double quotes as you type them. This can happen even while TextEdit is in plain text mode. Go to Edit > Substitutions in TextEdit and make sure Smart Quotes is unchecked. You can also disable this system-wide in System Preferences > Keyboard > Text > Use smart quotes and dashes. You can also opt for a fully-featured source code editor like Sublime Text, rather than using TextEdit.




回答2:


You are missing .htm / .html in links

<ul id="menu">
<li><a href="file:///Users/tamborine/Downloads/about_page.html">About</a></li>
<li><a href="file:///Users/tamborine/Downloads/the_therapist_page.html">The Therapist</a></li>
<li><a href="file:///Users/tamborine/Downloads/pay_what_you_can_page.html">Pay what you can</a></li>
<li><a href="file:///Users/tamborine/Downloads/projects_we_support_page.html">Projects we support</a></li>
<li><a href="file:///Users/tamborine/Downloads/resources_page.html">Resources</a></li>
<li><a href="file:///Users/tamborine/Downloads/prices_pag.html">Prices</a></li>
<li><a href="file:///Users/tamborine/Downloads/faq_page.html">FAQ</a></li>
</ul>



回答3:


Try typing all folder-names in small. And change in html also, i've ran into that couple of times




回答4:


I'll assume that you understand that you are linking to files on your computer -- this won't work if you try to put your webpage online, but it will work if you open the files locally.

I'm also assuming that all the files you're trying to link to are actually present in your downloads folder.

My assumption is that there is a typo somewhere in the filepath. It could be a case-sensitivity issue, or a file extension issue, or something else. The easiest way to eliminate this possibility is to open the file you want to link to in your browser. You might be able to just double-click on it, but if that doesn't work, you can open your browser and use file > open (or ctrl+O / cmd+o). Once the file is open, select everything in the URL bar and copy/paste it directly into your HTML. Do this for all the pages you're linking to, and if the links still don't work, something else is wrong and we'll need more details.



来源:https://stackoverflow.com/questions/30649114/why-are-some-of-my-html-internal-links-working-and-others-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!