Home > Article > Web Front-end > Does IE 6 Support HTML5 Custom Data Attributes?
Can IE 6 Handle HTML5 Custom Data Attributes?
The question arises whether custom data attributes introduced in HTML5 are functional in IE 6. Specifically, if an HTML element contains a custom attribute:
<div>
Can the following JavaScript retrieve the attribute's value:
var geoff = document.getElementById('geoff'); alert(geoff.dataGeoff);
Answer:
Contrary to the assumption, this technique works in IE 6. However, it's essential to use getAttribute instead of accessing the custom attribute directly via dataGeoff. The correct method is:
var geoff = document.getElementById('geoff'); alert(geoff.getAttribute('data-geoff'));
This approach is not specific to HTML5 but works with any custom attribute in IE6.
The above is the detailed content of Does IE 6 Support HTML5 Custom Data Attributes?. For more information, please follow other related articles on the PHP Chinese website!