Appendix JS_N_A2
Summary
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.
Examples
Correct code
Refer to the JS_N_A2 live demo for a working example.
Incorrect code
<form action="http://www.google.com/search" method="get"> <fieldset> <p> <label for="demo">Search for:</label> <input id="demo" name="q" type="text" /> </p> </fieldset> </form>
document.getElementById('demo').addEventListener('focus', function(e) { window.open('http://www.some-random-ad.com'); }, false);