Appendix JS_N_A2



Requirement: Changes of context are only initiated by user request or with user control.

Details: Use an actuation event, rather than focus or load event, to programmatically open links or trigger popup windows.


Correct code

Refer to the JS_N_A2 live demo for a working example.

Incorrect code

<form action="" method="get">
            <label for="demo">Search for:</label>
            <input id="demo" name="q" type="text" />
document.getElementById('demo').addEventListener('focus', function(e)
}, false);