锚< a> +链接到基本网址 [英] anchor <a> + Link to base URL
问题描述
如果我在一个页面上,比如
http://localhost/balibar.co/?dating = dating-articles-and-information
我想将链接到基本网址的链接定位为
http:// localhost / balibar.co
有没有一种方法可以在不对网址进行硬编码的情况下执行此操作?
我试过了:
< a href =/>< / a>
< a href =#>< / a>
将有几个域使用此页面,因此我不想对域名进行硬编码if可能。
< head>
< base href =http://www.google.com/>
< / head>
< body>
< a href => Google?< / a>
< / body>
该链接现在转到google.com
以下是证明:
您使用HTML的< base>
标签来指定基础所有使用 href
属性的元素的url。现在,任何具有 href
或 src
属性的标签都是空的,它会自动转到您在默认情况下是基本标记。
If I'm on a page like
http://localhost/balibar.co/?dating=dating-articles-and-information
and I want to have anchor that links to the base URL being
Is there a way to do this without hard coding the URL?
I've tried:
<a href="/"></a>
<a href="#"></a>
will have a few domains use this page so I don't want to hard code the domain name if possible.
<head>
<base href="http://www.google.com" />
</head>
<body>
<a href="">Google?</a>
</body>
That link will now go to google.com
Here is the proof:
You use HTML's <base>
tag to specify the base url for all elements that use the href
attribute. Now, any tag with an href
or src
attribute that is empty, it will automatically go to the url you specified in the base tag by default.
这篇关于锚< a> +链接到基本网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!