< a href>将链接附加到当前网址的末尾 [英] <a href> appends link to end of current url

查看:104
本文介绍了< a href>将链接附加到当前网址的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,每当我将一个.html文件上传到我的网站并使用新网址标记时,该链接就会使用户将链接附加到当前网址的末尾。例如,如果我的网站是example.com,而index.html文件放置在example.com/test中,而链接是google.com,则该链接会将我带到example.com/test/google.com。在这种情况下,如何使a href标签将我带到google.com。

So whenever I upload a .html file to my website and have tags the new url the link brings the user to appends the link to the end of the current url. For example, if my website was example.com and the index.html file was placed in example.com/test and the link was google.com then the link would bring me to example.com/test/google.com. How do I make it so the a href tag brings me to google.com in this case.

谢谢!

推荐答案

您应该真正了解绝对路径和相对路径。您正在使用的是相对路径。

You should really learn about absolute and relative paths. What you're using is a relative path.

这是服务器上的绝对路径:

This is an absolute path on your server:

<img src="/images/logo.png">

这是带有http协议的网址-打开Goog​​le.com

This is an url with http protocol - opens Google.com

<a href="http://google.com">Google</a>

这是一个没有显式协议的url,根据您的页面使用情况,它将变成http或https :

This is an url without explicit protocol, it will turn into http or https based on what your page uses:

<a href="//google.com">Google</a>

使用其中之一来满足您的需求(通常是http)。

Use one of those for what you need (typically the http one).

这篇关于&lt; a href&gt;将链接附加到当前网址的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆