Best Practice for JS - window.open() in href or in onclick?

compatibility, html, javascript, optimization

Solution

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.

Problem

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.

Original source