# @@@LINK= 能否跳转到条目指定位置？

**URL:** <https://forum.freemdict.com/t/topic/34883>\
**Category:** 技术交流与词典编修\
**Tags:** mdx, 词典, 求助\
**Created:** [2024 年12 月 15 日 16:02 UTC](https://forum.freemdict.com/t/topic/34883 "2024-12-15T16:02:55Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 15 日 16:02 UTC](https://forum.freemdict.com/t/topic/34883/1 "2024-12-15T16:02:55Z")

</div>

> `colour`  
> `@@@LINK=color`  
> `</>`

自动跳转到对应条目

> `<a href="entry://color#verb">see more</a>`

点选跳转到对应条目下的指定位置

能否将二者功能结合，直接自动跳转到对应条目下的指定位置？

---

<div class="post-metadata">

作者： ![shaoshi](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/shaoshi/32/14529_2.png) [@shaoshi](https://forum.freemdict.com/u/shaoshi)\
发布日期： [2024 年12 月 16 日 00:17 UTC](https://forum.freemdict.com/t/topic/34883/2 "2024-12-16T00:17:59Z")

</div>

有人研究过，其结论是：不能。

我个人也认为不能，除非词典软件作者改写软件。

---

<div class="post-metadata">

作者： ![wamich](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/w/c2a13f/32.png) [@wamich](https://forum.freemdict.com/u/wamich)\
发布日期： [2024 年12 月 16 日 03:32 UTC](https://forum.freemdict.com/t/topic/34883/3 "2024-12-16T03:32:16Z")

</div>

> [@格蕾特](#):
>
> colour

可以参考下：[js-mdx-server](https://github.com/wamich/js-mdx-server) 中 injection.js 文件

```js
  // 修复entry链接跳转问题
  function fixEntry() {
    const entryElements = document.querySelectorAll('a[href^="entry://"]');
    entryElements.forEach((el) => {
      el.addEventListener("click", (e) => {
        e.preventDefault();
        e.stopPropagation();

        const href = el.getAttribute("href");
        window.location = href.substring("entry:/".length);
      });
    });
  }

```

---

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 16 日 08:19 UTC](https://forum.freemdict.com/t/topic/34883/4 "2024-12-16T08:19:35Z")

</div>

> [@wamich](#):
>
> 可以参考下：[js-mdx-server](https://github.com/wamich/js-mdx-server) 中 injection.js 文件
> 
> ```auto
> // 修复entry链接跳转问题
> function fixEntry() {
> const entryElements = document.querySelectorAll('a[href^="entry://"]');
> entryElements.forEach((el) => {
> el.addEventListener("click", (e) => {
> e.preventDefault();
> e.stopPropagation();
> 
> const href = el.getAttribute("href");
> window.location = href.substring("entry:/".length);
> });
> });
> }
> 
> ```

看起来没变化呀，最后 `window.location = href.substring("entry:/".length);`，就是去掉前缀变成相对路径了而已。

---

<div class="post-metadata">

作者： ![137229](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/137229/32/90189_2.png) [@137229](https://forum.freemdict.com/u/137229)\
发布日期： [2024 年12 月 16 日 10:25 UTC](https://forum.freemdict.com/t/topic/34883/5 "2024-12-16T10:25:15Z")

</div>

只要你定义了 ID 随便跳

---

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 16 日 10:27 UTC](https://forum.freemdict.com/t/topic/34883/6 "2024-12-16T10:27:05Z")

</div>

> [@137229](#):
>
> 只要你定义了 ID 随便跳

有没有具体一些的操作方法？这方面不是很了解。

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2024 年12 月 16 日 10:32 UTC](https://forum.freemdict.com/t/topic/34883/7 "2024-12-16T10:32:37Z")

</div>

不能，没有通用的方法，容易出问题。

---

<div class="post-metadata">

作者： ![137229](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/137229/32/90189_2.png) [@137229](https://forum.freemdict.com/u/137229)\
发布日期： [2024 年12 月 16 日 10:39 UTC](https://forum.freemdict.com/t/topic/34883/8 "2024-12-16T10:39:49Z")

</div>

![1Q3EFSF%J5DN_@YGHLWM_DP](https://forumcdn.freemdict.com/uploads/default/original/3X/8/a/8ac21951864ef4fb8737ff25a74e1ee522a80bf6.png)  
定义个 锚跳 百度 锚点定位及跳转 看看

---

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 16 日 11:31 UTC](https://forum.freemdict.com/t/topic/34883/9 "2024-12-16T11:31:56Z")

</div>

> [@137229](#):
>
> ![1Q3EFSF%J5DN_@YGHLWM_DP](https://forumcdn.freemdict.com/uploads/default/original/3X/8/a/8ac21951864ef4fb8737ff25a74e1ee522a80bf6.png)
> 
> 定义个 锚跳 百度 锚点定位及跳转 看看

这个我知道，我想实现的功能是如下所述自动跳转到锚点。

> [@格蕾特](#):
>
> > `colour`  
> > `@@@LINK=color`  
> > `</>`
> 
> 自动跳转到对应条目

---

<div class="post-metadata">

作者： ![shaoshi](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/shaoshi/32/14529_2.png) [@shaoshi](https://forum.freemdict.com/u/shaoshi)\
发布日期： [2024 年12 月 16 日 12:06 UTC](https://forum.freemdict.com/t/topic/34883/10 "2024-12-16T12:06:59Z")

</div>

楼主是想这样跳：

\</\>  
colour  
@@@LINK=color#verb  
\</\>

我唯一能想到的方法是多跳一次，第一次跳到一个索引，点一下链接，再跳到词头内的特定锚点。

---

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 16 日 13:11 UTC](https://forum.freemdict.com/t/topic/34883/11 "2024-12-16T13:11:54Z")

</div>

> [@shaoshi](#):
>
> 我唯一能想到的方法是多跳一次，第一次跳到一个索引，点一下链接，再跳到词头内的特定锚点。

是这样的，我也只想到这个办法。想要这个功能是为了 [思高简体圣经.zip (3.5 MB)](https://forum.freemdict.com/t/topic/34834/13) 索引能够精确到节。

---

<div class="post-metadata">

作者： ![shaoshi](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/shaoshi/32/14529_2.png) [@shaoshi](https://forum.freemdict.com/u/shaoshi)\
发布日期： [2024 年12 月 16 日 13:20 UTC](https://forum.freemdict.com/t/topic/34883/12 "2024-12-16T13:20:24Z")

</div>

还有一种可能：

把每个节单独提取为一个词条。点按词条内的一个链接，可以跳到那一章，显示全文。

那样，@@@LINK就只需要跳到某一节。

---

<div class="post-metadata">

作者： ![格蕾特](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E6%A0%BC%E8%95%BE%E7%89%B9/32/69955_2.png) [@格蕾特](https://forum.freemdict.com/u/%E6%A0%BC%E8%95%BE%E7%89%B9)\
发布日期： [2024 年12 月 16 日 13:33 UTC](https://forum.freemdict.com/t/topic/34883/13 "2024-12-16T13:33:45Z")

</div>

> [@shaoshi](#):
>
> 把每个节单独提取为一个词条。点按词条内的一个链接，可以跳到那一章，显示全文。

确实可以，不过这样就更麻烦了，还需要单独提取出来。之后校对也要改两遍。
