Safari在锚链上不起作用 [英] Safari anchors on links not working

查看:134
本文介绍了Safari在锚链上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html定位符如下。

 < a name =template-8/> 
< h4 class =templateid =template-8>标题< / h4>

据我所知,浏览器应该跳到具有匹配名称或id属性的元素。 / p>

当我输入网址 http:/ /my.site.com/templates#template-8 safari按预期跳转页面。

但是,如下所示链接时,锚点什么也不做。 Chrome,Opera,IE7和Firefox都可以使用。

 < a href =http://my.site.com/模板#模板-8>链接< / a> 

Safari是5.0版本,可能是Safari浏览器的bug吗?

解决方案

问题是我在链接到的页面中有一个重定向头。



Opera,IE ,Chrome浏览器,Firefox将把锚点带到新页面。然而,safari失去了重定向的锚点。



如果Safari浏览器锚点遇到麻烦,请禁用任何重定向。


My html anchor is as follows.

<a name="template-8"/>
<h4 class="template" id="template-8">A title</h4>

As far as I know the browser should skip to the element with a matching name or id attribute.

When I type in the url http://my.site.com/templates#template-8 safari jumps down the page as expected.

However when linking as below the anchor does nothing. Chrome, Opera, IE7 and Firefox all work.

<a href="http://my.site.com/templates#template-8">A link</a>

Safari is version 5.0, could this be a safari bug?

解决方案

The problem was I had a redirect header in the page I was linking to.

Opera, IE, Chrome, Firefox will carry over the anchor to the new page. However safari loses the anchor on the redirect.

If you are having trouble with safari anchors disable any redirects.

这篇关于Safari在锚链上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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