如何在HTML中创建工作路径? [英] How to make working path in HTML?
问题描述
例如:a href =file:/// E:/赋值/主页面/ index.html#
它在我的计算机上工作,但它不会在另一个工作,我需要它在任何计算机上工作。
您的问题有两个方面:
如何让我的网站可以在任何地方访问?
您需要网络服务器,或者您需要使用 >托管公司 GoDaddy,1and1,HostGator和其他托管公司都配置了计算机(网络服务器),这些计算机被配置为向世界上的任何人展示他们的网页,每月费用大约10美元,能够创建链接,如 http://example.com/myproject/index.html
有可能你的教授会让你把你的网页放在校园里任何地方都可以访问的驱动器上,否则就是闪存驱动器我可以做一个捏。将文件放入闪存驱动器,然后将闪存驱动器上课。
是否有更好的方式来编写链接? em>相对网址在他们的链接中。例如,Stack Overflow不是将每个链接写成 http://stackoverflow.com/whatever
,而是通常使用相对URL: /任何
。
将 href
标签转换为网址时,浏览器会遵循一些简单规则(在此例如,我们从这个页面开始: http://stackoverflow.com/questions/15078748/how-to-make-working-path-in-html#15078792
)
- 如果链接以
http://
开头(或其他任何在
a://
之前),那么你的浏览器将会带你到那里。例如:
http://stackoverflow.com
会带您进入堆栈溢出主页。 - 如果链接从
/
开始,然后浏览器会在执行链接的其余部分之前将您带出
任何子文件夹。例如:
/ election
会带你到这里:http://stackoverflow.com/election
- 如果链接以
../
开头,那么它会向您发送一个文件夹
。这可以做多次。例如。../
会在这里寄给你
:http://stackoverflow.com/questions/
。 - 如果链接以
问号,&符号或哈希标记开头(?
,&
,#
),那么它通常会将
附加到您当前所在的任何页面。#example
会带你到
到
http://stackoverflow.com/questions/15078748/how-to-make例如
。 - 最后,浏览器会将您保留在当前文件夹中,然后
例如:示例
会将您发送到此处:
http://stackoverflow.com/questions/15078748/例如
So, currently I'm making a website. It's an assignment. And when I tried to open it on different computer, it didn't work.
So, for example: "a href="file:///E:/assignment/main page/index.html#"
It did work on my computer, but it won't work on another. I need it to work at any computer.
There are two halves to your question:
How do I make my website accessible anywhere?
You need a web server, or you need to use a hosting company. GoDaddy, 1and1, HostGator, and other hosting companies have computers (web servers) that are configured to show their webpages to anyone in the world. They cost around $10 per month, and you end up with the ability to create links such as http://example.com/myproject/index.html
It's possible that your professor will let you put your web pages on one of his drives that are accessible anywhere on campus. Otherwise, a flash drive can do in a pinch. Put the files onto a flash drive and then bring the flash drive to class.
Is there a better way to write links?
Most websites use relative URLs in their links. For example, Stack Overflow, instead of writing every link as http://stackoverflow.com/whatever
, will usually use a relative URL instead: /whatever
.
There are a few simple rules that your browser follows when turning an href
tag into a web address (in this example, we're starting from this page: http://stackoverflow.com/questions/15078748/how-to-make-working-path-in-html#15078792
)
- If the link starts with
http://
(or anything else that comes before a://
), then your browser will take you exactly there. For example:http://stackoverflow.com
takes you to the Stack Overflow home page. - If the link starts with
/
, then the browser will take you out of any subfolders before executing the rest of the link. For example:/election
will take you here:http://stackoverflow.com/election
- If the link starts with
../
, then it will send you exactly one folder up. This can be done multiple times. For example.../
will send you here:http://stackoverflow.com/questions/
. - If the link starts with a
question mark, ampersand, or hash tag, (
?
,&
,#
) then it will usually append this to whatever page you are currently on.#example
would take you tohttp://stackoverflow.com/questions/15078748/how-to-make-working-path-in-html#example
. - Finally, the browser will keep you in your current folder, then
send you to that link, for example:
example
will send you here:http://stackoverflow.com/questions/15078748/example
这篇关于如何在HTML中创建工作路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!