开发者

How well is insertAdjacentHTML supported?

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 highly recommend this article by John Resing - http://ejohn.org/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.com/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 compatible with, unfortunately, however it is provided detailed on this site (IE 4+).

See this reference for more information.

Addendum: This page provides some compatibility information, as well as sample code to catch incompatible 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.com/meteoric_cry/archive/2010/10/14/1851093.html. Just ignore the Chinese words...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜