Browser detect contenteditable features

喜夏-厌秋 提交于 2019-12-13 04:04:41

问题


I realise browser detection is not generally a good idea, however as each browser has a different implementation of contenteditable, I need a way to separate out my fixes for each.

Specifically:

gecko and webkit require a <br /> to be inserted at the end of empty paragraphs, otherwise they are automatically deleted.

ie and opera treat this <br /> as an ordinary <br /> and insert a newline.

I need a way to tell which browser or at least which of the implementations to use.

Please could you help me to find a method?

Thanks, Nico


回答1:


Actually, I decided to go with quite an interesting solution to this: Use css browser prefixes to detect the browser.

for instance if(elem.style["MozBorderRadius"] != undefined) targets firefox1+ and the same can be done with WebkitBorderRadius.



来源:https://stackoverflow.com/questions/3497942/browser-detect-contenteditable-features

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