Supporting IE8 with HTML5

南笙酒味 提交于 2020-01-07 02:21:32

问题


I've noticed that some websites I worked on years ago are now broken in IE8. It took a while to figure out but I see the file — http://html5shim.googlecode.com/svn/trunk/html5.js — that I've always used is now offline.

I don't often build websites these days so I'm a little out of touch. But have devs basically abandoned this browser now? or is there some other alternative file to fix it?


回答1:


If you just want to use HTML5 elements in IE8, for basic styling, you only need this

CSS

article,aside,dialog,figcaption,figure,footer,header,hgroup,
main,nav,section,details,mark,menu,summary { display:block; }

JS (run on load)

(function(d) {
  var e = 'article aside details figcaption figure footer header main mark menu nav section summary'.split(' '),i=e.length;
  while(i--) { d.createElement(e[i]); }
})(document);

Side note:

For IE9 one actually need this (if not use any library, as they normally does this already)

CSS

main { display:block; }


来源:https://stackoverflow.com/questions/38029127/supporting-ie8-with-html5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!