Determine the 'Overtype' mode using Javascript

后端 未结 3 413
遥遥无期
遥遥无期 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:11

    I suggest careful consideration of the 'overtype' feature. Does this behavior make sense in the web context, at all?

    What utility does the 'overtype' feature provides in the old ANSI presentation which is unavailable through the web?

    Unless I'm fully misunderstanding your question (apologies if so), I feel like the development intent may not align well with user expectations and typical web conventions.

    If the goal is to produce a page where:

    • by default 'insert' mode is disabled
    • user can trigger 'insert mode' for editing purposes

    ...then why not use dynamic form inputs?

    When a user clicks on a particular segment of HTML, a JavaScript is used to present the content as an element whose default value matches the chosen HTML tag.

    Once editing is completed the input is parsed, the page updated, and form input removed from display.

    Would this method suit your needs?

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-25 11:34

    The problem is that if the user presses the insert key after entering your page then you can track down it easily.

    But when the user has already pressed the insert key before entering your page then it seems to be a difficult task.

    0 讨论(0)
提交回复
热议问题