Determine the 'Overtype' mode using Javascript

后端 未结 3 418
遥遥无期
遥遥无期 2021-01-25 10:41

We are creating a web app to replace an old-school green-screen application. In the green-screen app, as the user presses the Insert key to switch between overtype and insert mo

3条回答
  •  一生所求
    2021-01-25 11:18

    In IE you can use document.queryCommandValue("OverWrite").

    For IE only:

    function isOverwriteEnabled() {
        try {
            // try the MSIE way
            return document.queryCommandValue("OverWrite");
        } catch (ex) {
            // not MSIE => not supported
            return false;
        }
    }
    

    Firefox, Chrome, and Safari:

    Because Mac does not have nor support the "insert" key, Safari will never ever support "insert" mode.

    For Chrome and Firefox, "insert" mode is not encouraged for support as Mac does not have it. (Also, see "Furthermore")

    That also means, since Windows supports "insert" mode, that IE will more than likely always support it.

    Furthermore:

    Firefox has a bug report classified as "WontFix" for years, so the "Insert" key will probably never be supported.

提交回复
热议问题