Answer the question
In order to leave comments, you need to log in
Cloning HTML5 elements in IE 6-8. Who will figure out how to get around the bug?
Have a nice time of the day.
Found a kind of bug.
After adding
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
Answer the question
In order to leave comments, you need to log in
Played around a bit in IE8 and found a solution. For those who do not understand, I will lay out an example for the author (who was either too lazy, or ...). Without jQuery of course :)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<nav class="demo">
1
</nav>
<div>
2
</div>
<script>
document.querySelector('body').appendChild(document.querySelector('nav').cloneNode(true));
console.log(document.querySelectorAll('nav')[1]);
document.querySelector('body').appendChild(document.querySelector('div').cloneNode(true));
console.log(document.querySelectorAll('div')[1]);
</script>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<nav class="demo">
1
</nav>
<div>
2
</div>
<script>
document.querySelector('body').innerHTML+=document.querySelector('nav').outerHTML;
console.log(document.querySelectorAll('nav')[1]);
document.querySelector('body').appendChild(document.querySelector('div').cloneNode(true));
console.log(document.querySelectorAll('div')[1]);
</script>
</body>
</html>
ie6:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<nav class="demo">
1
</nav>
<div>
2
</div>
<script>
document.body.innerHTML+=document.getElementsByTagName('nav')[0].outerHTML;
alert(document.getElementsByTagName('nav')[1]);
document.body.appendChild(document.getElementsByTagName('div')[0].cloneNode(true));
alert(document.getElementsByTagName('div')[1]);
</script>
</body>
</html>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question