相同页面锚链接到不在IE8中工作的部分ID [英] Same-page anchor links to section ids not working in IE8

查看:133
本文介绍了相同页面锚链接到不在IE8中工作的部分ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有导航的单页HTML5网站,该网站应该将用户发送到该部分。适用于所有浏览器,除了IE8,它没有做任何事情。我所拥有的Dummied版本:

I have a single-page HTML5 website with navigation that should send the user to that section. Works great in all browsers except IE8, which doesn't do anything. Dummied version of what I have:

<a href="#about">About</a>
<a href="#work">Work</a>
<a href="#services">Services</a>
<a href="#process">Process</a>
<a href="#contact">Contact</a>

<section id="about">
...
</section>

<section id="work">
...
</section>

<section id="services">
...
</section>

<section id="process">
...
</section>

<section id="contact">
...
</section>

搜索没有运气。看到一些关于向目标部分/ div添加不间断空格或一些文本的解决方案,但这不起作用。难倒。

Did a search with no luck. Saw some solutions about adding non-breaking spaces or some text to the targeted section/div, but that didn't work. Stumped.

推荐答案

首先,使用 name 而不是 id (或者可能 name 以及 id ,如果你还需要将id用于其他内容。)

Firstly, use name rather than id (or possibly name as well as id, if you also need to use the id for something else).

<section name="work">

其次,IE8及更早版本不支持新的HTML5元素,如< ; section>

Secondly, IE8 and earlier doesn't support the new HTML5 elements like <section>.

为了解决这个问题,您需要使用像 html5shiv 。 (或使用内置html5shiv的 Modernizr )。

In order to fix this, you need to use a hack like the html5shiv. (or use Modernizr which has html5shiv built in).

两者html5shiv和Modernizr是基于Javascript的。如果您因任何原因不想或不能使用它们,那么您将不得不切换到使用IE8支持的HTML标记,例如< div>

Both html5shiv and Modernizr are Javascript based. If you don't want to or can't use them for whatever reason, then you'll have to switch to using HTML tags that IE8 does support, like <div>.

希望有所帮助。

这篇关于相同页面锚链接到不在IE8中工作的部分ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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