Best Practice for JS - window.open() in href or in onclick?
问题 Just a question about optimization, between : <a href="#" onClick="javascript:window.open('myUrl.com');">link-1</a> and : <a href="javascript:window.open('myUrlBis.com');">link-2</a> Is one better than the other ? Or more compatible ? Thanks. 回答1: Best practice is to use the target attribute: <a href="http://myUrl.com" target="_blank">link-1</a> If that doesn't suit, a click handler (ideally not assigned via attribute) would be my take. 回答2: Neither one Make it a regular link using href and