Opera Bug #334045

[Regression] Setting the onmousedown property of the document to return false; prevents document focus.

Affects up to Opera 12.15

This page is set up to alert the keycode of all keys pressed while it has focus. When the keydown event handler is preceded by a statement which sets the value of the onmousedown property of the document (or documentElement) to return false; this can prevent Opera from focusing the document, causing any scripting interaction to fail. Setting the onmousedown event of an element to return false; is a common means to prevent text selection in many scripts online.

To manifest the bug, open this page, click another visible document (such as sidebar panels) to blur this document, then click the document to try to focus it again. Opera correctly focuses the document and re-enables interaction in 9.2x, but fails completely to focus the document in 9.5, completely disabling interactivity with the document. Opera keyboard shortcuts, or clicking the page's tab in the tab bar, can be used to focus the document again, re-enabling interactivity. Until the user figures this out, however, the document or web-application appears broken for no apparent reason.

This is a regression in Opera 9.5. It is worth noting that if the onmousedown event handler is attached to the document using the addEventHandler method instead of assigning it to the property value, this bug does not appear.

Main Bug List