如何创建到网页子部分的深层链接? [英] How do I create a deeplink to a subsection of a web page?

查看:95
本文介绍了如何创建到网页子部分的深层链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道我如何创建指向单个网页的子部分的深层链接吗?

Does anyone know how I can create a deeplink to a subsection of an individual web page?

Wiki似乎已破解,但我似乎无法在网络上的任何地方找到答案.

Wiki seem to have it cracked but I can't seem to find the answers anywhere on the web.

PS:请保持简单!

推荐答案

仅当目标包含组成目标锚"的标记(可以在片段标识符中使用)时,才可以链接到页面上的特定位置或元素.(以#开头)在链接中.下面创建此类锚点:

Linking to a specific location or element on a page is possible only if the destination contains markup that constitutes a "destination anchor" that you can use in a fragment identifier (starting with #) in a link. The following create such anchors:

  • id 属性(在任何元素上)
  • a 元素上的 name 属性
  • An id attribute (on any element)
  • A name attribute on an a element

前者是一种现代的更可取的方式,它使您可以引用一个元素,而不仅仅是位置(点)或内联元素.例如,如果目标页面 http://www.example.com/stuff.html 包含

The former is the modern, preferable way and lets you refer to an element, not just a location (point) or just an inline element. For example, if the destination page http://www.example.com/stuff.html contains

<div class="section" id="sec7">
<h2>Foo bar</h2>
<p>Some text.</p>
Any other content
</div>

然后您可以使用类似的链接

then you can use a link like

<a href="http://www.example.com/stuff.html#sec7">Foo bar</a>

这篇关于如何创建到网页子部分的深层链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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