user247702
user247702

Reputation: 24232

Why do I get a jQuery error when using html5shiv?

The following code generates a jQuery error:

<!doctype html>
<title>jquery-test.html</title>
<script src="http://cdn.jsdelivr.net/html5shiv/3.7.0/html5shiv.js"></script>
<header>
    <hr>
</header>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>

Unknown runtime error jquery-1.10.2.js, line 3489 character 3

line 3489: div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";

Upvotes: 0

Views: 630

Answers (1)

user247702
user247702

Reputation: 24232

html5shiv requires an explicit <body> tag (GitHub issue). The following works correctly:

<!doctype html>
<title>jquery-test.html</title>
<script src="http://cdn.jsdelivr.net/html5shiv/3.7.0/html5shiv.js"></script>
<body>
    <header>
        <hr>
    </header>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
</body>

In the simplest case you'll just get a blank screen without errors. When adding additional content like HTML or scripts, you may get obscure errors.

Upvotes: 2

Related Questions