最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How well is insertAdjacentHTML supported? - Stack Overflow

programmeradmin2浏览0评论

I recently discovered the insertAdjacentHTML method and it's a god-send. Being such I wanted to know how well this method is supported. Does IE have it? What about Chrome?

I recently discovered the insertAdjacentHTML method and it's a god-send. Being such I wanted to know how well this method is supported. Does IE have it? What about Chrome?

Share Improve this question asked Sep 8, 2011 at 0:53 David GDavid G 96.8k41 gold badges172 silver badges257 bronze badges 0
Add a ment  | 

4 Answers 4

Reset to default 3

I highly remend this article by John Resing - http://ejohn/blog/dom-insertadjacenthtml/

Basically, it works on IE since IE4, and it is going to be a part of HTML5. There are also few limitations on which HTML elements you want to call this code on.

The documentation page on MDN indicates that all browsers have been supported it for a while except Firefox which will introduce its support in version 8.

If you want to use it now and make sure older versions of Firefox support it (although they will disappear in few months) you can put this insertAdjacentHTML polyfill (shim) in your site and the method will work everywhere.


Update: As the above shim is deleted, you can use https://gist.github./1276030

Yes, it is supported in Chrome and Internet Explorer, as well as later versions of Firefox and Opera. I couldn't narrow down which versions of IE it was patible with, unfortunately, however it is provided detailed on this site (IE 4+).

See this reference for more information.

Addendum: This page provides some patibility information, as well as sample code to catch inpatible browsers. Please note, however, that contrary to that site Firefox is supported, but only in recent iterations and in some cases in limited functionality.

Try code here http://www.cnblogs./meteoric_cry/archive/2010/10/14/1851093.html. Just ignore the Chinese words...

发布评论

评论列表(0)

  1. 暂无评论