The online exam page often needs to detect if the user is cheating.
Generally is the way to monitor the page is out of focus, and there are many ways to lose focus, such as QQ pop-up window, switch page, switch program, input file upload Select file, etc.
Selecting files is normal, in which case you need to filter
This article is very simple, actually is the use of document.activeelement , get the focus element on the current page
You can trigger a mouse click or tab toggle to get
Generally, form input, textarea, select, and so on, is also the body item
<inputtype= "text"name=""> <inputtype= "File"name=""> <Scripttype= "Text/javascript">Window.onblur= function() { varElem=document.activeelement; Console.log (Elem); if(Elem.getattribute ('type') !== 'file') {Console.log ('Blur'); } }; </Script>
Filter the file selection caused by the pop-up window, the support of this property is still possible
However, the use of JS detection is QQ pop-up window, at present, still does not work, had to prompt users to close the test before the application may be pop windows
Document.activeelement Filter Select File Pop-up causes page loss