Google chrome - How to detect if browser supports quotplaintext-onlyquot value in contenteditable parameter

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I can t find any relevant information about "contenteditable" HTML5 parameter. I ve found out, that Google Plus is using this for Chrome browsers:

<div contenteditable="plaintext-only"></div>

It seems that no other browsers support this and it s only Chrome proprietary value. I want to use it in my project. However, I need to detect the browser and find out if supports "plaintext-only" setting.

Of course, I could detect only Chrome, but there might be other browsers that support it (I don t know about any at this moment) or other main stream browsers might start supporting this feature in future.

So I would rather detect if the "plaintext-only" functionality is supported than detecting just Chrome browser.

Anyone can help me on this ?

Answers

http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable

https://www.w3.org/Bugs/Public/show_bug.cgi?id=14554 https://www.w3.org/Bugs/Public/show_bug.cgi?id=14554

Edit: http://jsfiddle.net/e9t2d/1/ http://jsfiddle.net/e9t2d/1/

function supportsPlainText()
{
    var d = document.createElement("div");
    try {
        d.contentEditable="PLAINtext-onLY";
    } catch(e) {
        return false;
    }
    return d.contentEditable=="plaintext-only";
}

alert(supportsPlainText());

But remember that doing browser-specific pages it s what leaded us to the IE6 problem.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/10672081/how-to-detect-if-browser-supports-plaintext-only-value-in-contenteditable-para

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils