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

查看:213
本文介绍了什么是片段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天全站免登陆