浏览器检测可编辑的功能 [英] Browser detect contenteditable features

查看:217
本文介绍了浏览器检测可编辑的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现浏览器检测通常不是一个好主意,但是因为每个浏览器都有一个不同的实现contenteditable,我需要一个方法来分离我的修补程序为每个。



具体来说:



gecko和webkit需要在结尾处插入< br /> 空的段落,否则会自动删除。



ie和opera将此< br />



我需要一种方法来告诉哪个浏览器或哪个浏览器



您能帮我找到一个方法吗?



Nico

解决方案

实际上,我决定使用一个有趣的解决方案:使用css浏览器前缀来检测浏览器。 / p>

例如 if(elem.style [MozBorderRadius]!= undefined)定位firefox1 +使用WebkitBorderRadius。


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

解决方案

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.

这篇关于浏览器检测可编辑的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆