找回密码
 快速注册
搜索
查看: 35|回复: 8

<base>

[复制链接]

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-6-8 21:30 |阅读模式
\begin{equation}\label{eq1}
a^2+b^2=c^2
\end{equation}
\eqref{eq1}
引用的链接还真不对呢,不知啥原因

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

点评

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

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

 楼主| kuing 发表于 2022-6-8 22:12
LS
  1. <a href="#pid46050">LS</a>
复制代码
我用这样的链接也是指向首页……

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-7-18 02:43

搜到了相同的问题

本帖最后由 hbghlyj 于 2024-3-17 00:58 编辑
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')
    })
  }
})

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-7-27 07:38


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>
是正常的.
难道只能导向到别的页面,导向到当前页就会清空吗

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-7-27 08:04
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.

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-7-27 08:17
本帖最后由 hbghlyj 于 2024-3-22 15:19 编辑

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>
成功了

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

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

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

 楼主| kuing 发表于 2024-3-17 21:48
hbghlyj 发表于 2024-3-17 08:55
kuing 发表于 2022-6-8 13:30
引用的链接还真不对呢,不知啥原因
……两年后)

手机版还是有 <base>,可能当时忘了考虑手机版……

点评

已经好了。  发表于 2024-3-17 21:52

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:30

Powered by Discuz!

× 快速回复 返回顶部 返回列表