Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

onauxclick — auxiliary-button click handler

The onauxclick attribute assigns JavaScript code to the auxclick event, associated with clicking a non-primary pointing-device button. It can be used on all HTML elements.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

onauxclick="JavaScript statements"

onauxclick is a global HTML event-handler attribute. It handles the auxclick event, associated with clicking a non-primary button, such as the middle mouse button. It is not a replacement for onclick.

The attribute value is a JavaScript function body, not a URL or event name. The code receives the event object. Its corresponding DOM property, onauxclick, accepts a function or null; the attribute written in HTML instead contains code as text.

Content Security Policy can block this inline event handling. Do not insert untrusted text into the attribute value: it is executable code.

The example dispatches auxclick programmatically, so it does not require a mouse with an auxiliary button. It tests the connection between the attribute and its handler, not physical-device behavior or native browser actions.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onauxclick example</title>
<button id="target" type="button" onauxclick="document.getElementById('result').textContent = event.type;">Test target</button>
<output id="result">Waiting</output>
<script>
  document.getElementById('target').dispatchEvent(
    new MouseEvent('auxclick', { button: 1, bubbles: true })
  );
</script>
</html>

Result

auxclick

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources