== Why is this an issue?

There are two ways to build a link that has the sole purpose of running JavaScript code. The goal of this rule is to ban such patterns in order to support browsing with JavaScript disabled.


=== Noncompliant code example

[source,html]
----
<a href="#" onclick="alert('Clicked!'); return false;">Run JavaScript Code</a> <!-- Noncompliant -->
<a href="javascript:void(0)" onclick="alert('Clicked!'); return false;">Run JavaScript Code</a>  <!-- Noncompliant -->
<a id="inPageAnchor">Jump down the page to me</a>  <!-- Compliant -->
----


=== Compliant solution

[source,html]
----
<a id="inPageAnchor">Jump down the page to me</a>  <!-- Compliant -->
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Replace this 'href' value by a link to an existing page or anchor.


'''
== Comments And Links
(visible only on this page)

=== on 19 Jun 2013, 09:16:25 Dinesh Bolkensteyn wrote:
It seems that there is a difference between the 2 patterns.


* # will scroll back up to the top of the page.
* javascript:void(0) does not affect the scrollbar.

But indeed with the return false; in the onclick, both do the same.

=== on 19 Jun 2013, 09:48:12 Dinesh Bolkensteyn wrote:
I'm wondering if this rule should also apply to href="" or not.

=== on 8 Jul 2013, 18:25:37 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARPLUGINS-2984

endif::env-github,rspecator-view[]
