Forgot password?
 Create new account
View 115|Reply 8

<base>

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2022-6-8 21:30:16 |Read mode
\begin{equation}\label{eq1}
a^2+b^2=c^2
\end{equation}
\eqref{eq1}
引用的链接还真不对呢,不知啥原因

在旧论坛测试没有问题,奇怪呢……

Comment

公式的解决了,但楼下的还是一样,不过无所谓了,就酱吧  Posted at 2022-6-9 03:37
<base>有什么用呢  Posted at 2022-8-17 04:57

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2022-6-8 22:12:35
LS
  1. <a href="#pid46050">LS</a>
Copy the Code
我用这样的链接也是指向首页……

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-18 02:43:37

搜到了相同的问题

Last edited by hbghlyj at 2024-3-17 00:58:00
kuing 发表于 2022-6-8 15:12
我用这样的链接也是指向首页……
搜到了相同的问题
Make anchor links refer to the current page when using <base>
base href to / - now href to IDs not working
Using anchors on a page with <base> set
用选择器 'a[href^="#"]' 可以选择以#开头的链接
document.addEventListener('DOMContentLoaded', function(){
  var es = document.querySelector('a[href^="#"]')
  for(var i=0; i<es.length; i++){
    es[
i].addEventListener('click', function(e) {
      e.preventDefault()
      document.location.hash = e.target.getAttribute('href')
    })
  }
})

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-27 07:38:13
Discuz的遗留问题
暂时可以用2#
<a onclick="location.hash='#pid46755'">2<sup>#</sup></a>
达到效果. 但是CSS的cursor属性为auto(缺省值)时,如果<a>元素无href属性则为cursor:text,有href属性则为cursor:pointer
加上一个占位href属性变为2#
<a href="javascript:void(0);" onclick="location.hash='#pid46755'">2<sup>#</sup></a>
或者写成 <a href="javascript:;" onclick="location.hash='#pid46755'">2<sup>#</sup></a>
但是如果写成 <a href="#" onclick="location.hash='#pid46755'">2<sup>#</sup></a> 就会跳至首页(因为这里设置了<base>为主页)

最简单的方法应该是把脚本写到href里,就不用写onclick: 2#
<a href="javascript:location.hash='#pid46755'">2<sup>#</sup></a>
会把页面清空,不知何故

测试一个其他的javascript开头的href属性 2#
<a href="javascript:alert(1)">2<sup>#</sup></a>
是正常的
再测试一个其他的javascript开头的用于重定向页面的脚本 2#
<a href="javascript:location.href='https://google.com'">2<sup>#</sup></a>
也是正常的. 那么就不去更改location.hash,而是直接改location.href应该是可以的. 试一下: 2#
<a href="javascript:location.href=location.href.slice(0,-location.hash.length)+'#pid46755'">2<sup>#</sup></a>
又会把页面清空,不知何故
如果直接改location.href而不计算, 试一下: 2#
<a href="javascript:location.href='https://kuing.cjhb.site/forum.php?mod=viewthread&tid=9020&page=3&extra=#pid46755'">2<sup>#</sup></a>
又清空了.
导向到主页试一下: 2#
<a href="javascript:location.href='https://kuing.cjhb.site'">2<sup>#</sup></a>
是正常的.
难道只能导向到别的页面,导向到当前页就会清空吗

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-27 08:04:19
developer.mozilla.org/en-US/docs/Web/API/History/pushState
But pushState() has a few advantages:

    The new URL can be any URL in the same origin as the current URL. In contrast, setting window.location keeps you at the same document only if you modify only the hash.

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-27 08:17:23
Last edited by hbghlyj at 2024-3-22 15:19:00
hbghlyj 发表于 2022-7-27 00:38 本帖最后由 hbghlyj 于 2022-7-27 01:01 编辑 Discuz的遗留问题 暂时可以用2# <a onclick="location.hash= ...
见Mozilla文档void operator
The void operator can be used to return undefined. For example:
Click here for green background
<a href="javascript:void(document.body.style.backgroundColor='green');">
  Click here for green background
</a>
用void的写法是 2#
<a href="javascript:void(location.hash='#pid46755')">2<sup>#</sup></a>
成功了

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2024-3-17 08:55:54
kuing 发表于 2022-6-8 13:30 引用的链接还真不对呢,不知啥原因
……两年后)
手机版引用的链接仍不对呢,不知啥原因

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2024-3-17 21:48:32
hbghlyj 发表于 2024-3-17 08:55
kuing 发表于 2022-6-8 13:30
引用的链接还真不对呢,不知啥原因
……两年后)
手机版还是有 <base>,可能当时忘了考虑手机版……

Comment

已经好了。  Posted at 2024-3-17 21:52

手机版Mobile version|Leisure Math Forum

2025-4-20 22:11 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list