缩短HTML中包含锚标记的长代码行



我想在我的文本上最大字符长度为80个字符。它被长长的链接所阻止,我找不到一种方法来缩短实际代码。不是在网站上,而是在实际代码上。只是为了让它看起来更干净,更短,而不使用short .

我有一个长链接的例子是:

<a href="https://www.ukrinform.net/rubric-polytics/3308431-usukraine-strategic-partnership-commission-to-meet-this-fall.html">

但是我想在代码中把它切成两半所以它会像这样显示:

<a href="https://www.ukrinform.net/rubric-polytics
/3308431-usukraine-strategic-partnership-commission-to-meet-this-fall.html">

所有我得到的是错误,它采取的第一部分,包含换行符的链接。我找不到任何方法来解决这个问题。

我想知道是否有可能的方法可以做类似的事情。

选项1

你可以使用url缩短器之类的东西,然后在你的代码中传递缩短的链接。

网址缩写服务

  • https://bit.ly
  • https://shorturl.a
  • https://cutt.ly

选项2

你可以用一个链接列表创建另一个网页,并使用GET请求访问它们。

如果您正在使用PHP:

<script>
const links = [
"https://long-link-1.com",
"https://long-link-2.com",
"https://long-link-3.com"
]
window.location.replace(links[<?php echo $_GET["linkID"]; ?>-1])
</script>

显示网页(示例):

<a href="/longlinks.php?linkID=1"></a>

最新更新