how to make a DIV unfocusable?

前端 未结 5 1614
情深已故
情深已故 2021-02-07 10:16

I met a problem about HTML rendering.

In dir=\"rtl\" document of IE7, when JavaScript tries to set focus to a DIV element(with oElement.focus() method), the rendering tu

5条回答
  •  心在旅途
    2021-02-07 10:48

    I'm not sure if you can make an element 'un-focusable', but you can certainly un-focus it at a specific point in time using its blur method:

    document.getElementById("myElement").blur();
    

    EDIT:

    I think you can make an element 'un-focusable' by defocusing it every time it is focused. You can accomplish this via:

    document.getElementById("myElement").onfocus = function() {
        this.blur();
    };
    

    ...or (using inline Javascript in your HTML):

    Steve

提交回复
热议问题