Do you use Hyperlinks instead of JavaScript to open pages?

Last updated by Brook Jeynes [SSW] 8 months ago.See history

If possible you should always use hyperlinks to open new pages on your site instead of using JavaScript.

There are two good reasons for avoiding JavaScript-powered links:

  1. Copying and pasting sections of the site to an email or a document will maintain the clickable links
  2. There's an (ever-decreasing) chance a user won't have JavaScript enabled and won't be able to click the link
<div onclick="window.open('mynewpage.html');">Open a new page</div>

Figure: Bad Example - This link can't be clicked on if you paste it into an email or if JavaScript is off

<a href="mynewpage.html">Open a new page</a>

Figure: Good Example - This link can still be clicked on when pasted and when JavaScript is turned off

We open source. Powered by GitHub