Safari单击超链接时会忽略/删除锚点(或“标签”)吗? [英] Safari ignoring/removing anchors (or "hashtags") when clicking hyperlinks?

查看:89
本文介绍了Safari单击超链接时会忽略/删除锚点(或“标签”)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一页指向另一页,然后滚动到特定部分。在Chrome和Firefox中,使用 www.example.com#section1 这样的URL可以达到目的。 (#section1可以是锚点或元素的ID)。

I need to point one page to another and then scroll to a particular section. In Chrome and Firefox, using an URL like www.example.com#section1 does the trick. (#section1 can be an anchor or an element's id).

但是,在Safari中,当我单击链接时,哈希消失了。

However, in Safari, the hash disappears when I click the link.

为什么会这样?可以在Safari上执行吗?如果没有,我该如何解决这个问题?

Why is this happening? Is it possible to do it on Safari? If not, how can I get around this problem?

推荐答案

使用指向其他页面内部部分的超链接时,您必须记住在#标签之前添加斜杠(/),以实现跨浏览器兼容性。

When using hyperlinks that point to inside sections on other pages you must remember to add a slash (/) before the hashtag for cross browser compatibility.

例如: www.example.com/#item-1

这样做 www.example.com#item-1 并非所有浏览器都接受(显然是Chrome和Firefox)

doing www.example.com#item-1 isn't accepted by all browsers (apparently by Chrome and Firefox it is)

这篇关于Safari单击超链接时会忽略/删除锚点(或“标签”)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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