点击超链接时,Safari忽略/删除hashatags? [英] Safari ignoring/removing hashatags when clicking hyperlinks?

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

问题描述

我需要将一个页面指向另一个页面,然后滚动到特定部分。在Chrome中执行www.example.com#section1会做到这一点(#section1可以是锚点或元素的id)。



我已经在Chrome和Firefox中尝试过了,在两个浏览器中,它工作正常(带我到页面,然后自动滚动到锚点,但在safari的哈希消失时,我点击链接。



为什么会发生这种情况?是否可以在Safari上执行此操作,如果没有,我该如何解决这个问题?

解决方案

当使用指向其他页面上的部分的超链接时,必须记住在主题标签之前添加一个斜杠(/ p>

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



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


I need to point one page to another and then scroll to a particular section. In Chrome doing www.example.com#section1 would do the trick (#section1 can be an anchor or an element's id).

I have tried it in Chrome and Firefox and in both browsers it works fine (takes me to the page and then scrolls automatically to the anchor however in safari the hash disappears when I click the link.

Why is this happening? Is it possible to do it on Safari, if not how can I go 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.

Eg: www.example.com/#item-1

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

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

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