Browser detect contenteditable features

2019-08-30 22:49发布

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条回答
Juvenile、少年°
2楼-- · 2019-08-30 22:59

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.

查看更多
登录 后发表回答