什么是片段 URL,为什么要使用它们? [英] What are fragment URLs and why to use them?

查看:43
本文介绍了什么是片段 URL,为什么要使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PHP 开发的新手.

I am new to PHP Development.

今天我遇到了 URL 片段的有趣话题,特别是 URL 的 # 部分.

Today I came across the interesting topic of URL fragments, specifically the # part of URLs.

我搜了一下,发现好像

www.example.com/foo.html#bar

但我不明白为什么需要这个 #bar.或者如何在PHP中读取?

But I don't understand why this #bar is needed. Or how to read it in PHP?

推荐答案

片段是内部页面引用,有时称为命名锚点.它通常出现在 URL 的末尾,以井号 (#) 字符开头,后跟标识符.它指的是网页中的一个部分.

A fragment is an internal page reference, sometimes called a named anchor. It usually appears at the end of a URL and begins with a hash (#) character followed by an identifier. It refers to a section within a web page.

在 HTML 文档中,浏览器查找名称属性与片段匹配的锚标记.

In HTML documents, the browser looks for an anchor tag with a name attribute matching the fragment.

关于片段有一些事情,最重要的可能是它们不是在 HTTP 请求消息中发送的,但您可以在 此页面.

There are a few things about the fragments, the most important may be that they aren't sent in HTTP request messages but you can find some more info about them on this page.

Javascript 可以操作当前页面上的片段,可用于为页面添加历史记录条目,而无需强制完全重新加载.

Javascript can manipulate fragments on the current page which can be used to to add history entries for a page without forcing a complete reload.

这篇关于什么是片段 URL,为什么要使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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