问题描述
我是HTML世界的新手.
I'm new to HTML world.
我在服务器上创建了"example.html" 网页,
其中包含以下 a标签链接.
I created a "example.html" web page at server,
which contains following a tag links.
...
<nav>
<ol>
<li><a href="http://localhost/link1.html">link1</a></li>
<li><a href="http://localhost/link2.html">link2</a></li>
<li><a href="http://localhost/link3.html">link3</a></li>
</ol>
</nav>
...
如果我在服务器的Web浏览器上打开此"http://localhost/example.html"
页面,然后单击链接(link1〜link3),它们将起作用.
If I open this "http://localhost/example.html"
page on server's web browser and click on links(link1~link3), they work.
问题在于它们无法在客户端的Web浏览器上运行.
The problem is that they DO NOT WORK on client's web browser.
我端口转发了我的服务器计算机,并从客户端打开了"example.html"
,
通过"http://myaddress.com:1234/example.html"
I port-forwarded my server computer and opened "example.html"
from client,
through "http://myaddress.com:1234/example.html"
暂时,我通过更改来解决了
服务器代码中的每个链接,"http://localhost/~~~.html"
到"http://myaddress.com:1234/~~~.html"
.
Temporarily, I solved it by changing
every link in server's code, "http://localhost/~~~.html"
to "http://myaddress.com:1234/~~~.html"
.
但是,我想使客户端能够访问服务器代码中以"http://localhost/~~~.html"
However, I want to enable client to access every link in server's code written as "http://localhost/~~~.html"
是端口转发问题吗?还是其他?
Is it the problem of port-forwarding? or something else?
非常感谢您.
推荐答案
这应该可以解决问题,您的href不需要本地主机.从锚标签中删除它们.
This should solve the problem, you don't need localhost in your href's. Remove them from your anchor tags.
<nav>
<ol>
<li><a href="/link1.html">link1</a></li>
<li><a href="/link2.html">link2</a></li>
<li><a href="/link3.html">link3</a></li>
</ol>
</nav>
OR
尝试将端口附加到localhost href吗?客户端必须在本地运行它才能起作用.
Try attaching the port to the localhost href? The client must be running it locally for this to work.
<nav>
<ol>
<li><a href="http://localhost:1234/link1.html">link1</a></li>
<li><a href="http://localhost:1234/link2.html">link2</a></li>
<li><a href="http://localhost:1234/link3.html">link3</a></li>
</ol>
</nav>
这篇关于链接"href = http://localhost/~~~"客户端无法访问服务器上HTML代码中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!