[英]HTML anchor tags not working in Firefox, Safari, iPad and iPhone
My html anchor tags work in chrome and IE but in Firefox, Safari, iPad and iPhone they do not work, how come? 我的html锚标签在chrome和IE中工作,但在Firefox,Safari,iPad和iPhone中它们不起作用,怎么样? and what can I do to fix it?
我该怎么做才能解决这个问题?
<a href="/services#underpinning">Underpinning</a>
Any help would be appreciated. 任何帮助,将不胜感激。
Thanks. 谢谢。
This is what I am trying to link it to on the services
page: 这是我试图将其链接到
services
页面上的内容:
<h1 id="#underpinning" name="underpinning">Underpinning</h1>
This is where I left off: 这是我离开的地方:
This is my link: 这是我的链接:
<li><a href="/services#underpinning"><h2 id="underpinning">Underpinning<a href="services#underpinning"><img class="alignnone size-full wp-image-127" alt="home" src="http://powellgroupconstruction.com/wp-content/uploads/2013/12/home.jpg" width="500" height="337"></a></h2></a></li>
This is where on my services page I want the link to goto: 这是我的服务页面上我希望链接转到的地方:
<a name="underpinning"><h1 id="underpinning" name="underpinning">Underpinning</h1></a>
If I goto the url directly: http://powellgroupconstruction.com/services/#underpinning into safari or firefox, it works. 如果我直接转到网址: http : //powellgroupconstruction.com/services/#underpinning到safari或firefox,它的工作原理。
There are several issues in your code. 您的代码中存在几个问题。 On your example website you're using
HTML5 Doctype
, so I'm just answering respectively with HTML5 in mind: 在您的示例网站上,您使用的是
HTML5 Doctype
,所以我只是分别回答HTML5:
name
attribute in general and <a name>
markup as link target in particular. name
属性 ,特别是<a name>
标记作为链接目标 。 id
as a link target . id
作为链接目标 。 id
more than once . id
。 From the HTML5 spec again: <a id="underpinning" name="underpinning"><h1 id="underpinning" name="underpinning">Underpinning</h1></a>
<h1 id="underpinning">Underpinning</h1>
/services#underpinning
. /services#underpinning
。 As you're going with the WordPress rewrite functionality, entering http://powellgroupconstruction.com/services
gets redirected to http://powellgroupconstruction.com/services/
. http://powellgroupconstruction.com/services
会被重定向到http://powellgroupconstruction.com/services/
。 <a href="/services/#underpinning">Underpinning</a>
You are using the same id in multiple elements. 您在多个元素中使用相同的ID。 The id needs to be unique, make sure you use each id only once and it should work.
id必须是唯一的,确保你只使用每个id一次,它应该工作。
Are href for both h2 and img tags are same? h2和img标签的href是否相同? then have you tried this one:
然后你试过这个:
<a href="services#underpinning">
<h2 id="underpinning">Underpinning
<a href="services#underpinning"><img class="alignnone size-full wp-image-127" alt="home" src="http://powellgroupconstruction.com/wp-content/uploads/2013/12/home.jpg" width="500" height="337">
</a></h2>
</a>
I had an issue very similar to this. 我有一个与此非常相似的问题。 I believe your problem is that Firefox and Safari do not like an
<h2>
tag inside an anchor <a>
tag. 我相信你的问题是Firefox和Safari不喜欢锚
<a>
标签内的<h2>
标签。 Try : 试试:
<a href="/services#underpinning"><span id="underpinning">Underpinning</span></a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.