开发者

HTML5 shiv not working when DOCTYPE declared

I can’t understand this. The HTML5 shiv is not working in IE 8 and lower when I declare the HTML5 doctype. It only works when there开发者_运维技巧 is no doctype. Why could this be? I have the shiv between the <head> tags, I have it before anything else (styles, other scripts) and it won’t work.

Generally the start of the page looks standard way like this:

<!DOCTYPE html>
<html lang="cs">
<head>
  <meta charset="utf-8">
  <title>Title</title>
  <script src="/html5.js" type="text/javascript"></script>
  <link href="/style.css" rel="stylesheet" type="text/css">
</head>


I was able to replicate your issue locally in IE8, and conclude that it's in the way you reference the html5.js file. Change your mark-up like so:

<!DOCTYPE html>
<html lang="cs">
<head>
  <meta charset="utf-8">
  <title>Title</title>
  <script src="html5.js" type="text/javascript"></script>
  <link href="style.css" rel="stylesheet" type="text/css">
</head>

--i.e. remove the preceding "/" -- and all will be well. Worked for me. Counter-intuitive I grant you, but hey, welcome to the world of IE.

EDIT You say this still isn't working. This may be a daft question, but you are setting the HTML5 entities like section, aside, header etc. with the appropriate display attribute, aren't you? You don't provide the content of your stylesheet 'style.css' but you need to do this for things like section:

section {display: block}


Modernizer is also worth a try if your still having problems..

Modernizer Homepage


Manipulate the shiv, and put an alert('something') in it. See if it alerts anything or not. If not, then it's not executed, and we should see why. If yes, then maybe it's corrupt. Download the latest version from here. Use this shiv

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜