23 lines
684 B
Plaintext
23 lines
684 B
Plaintext
== 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,text]
|
|
----
|
|
<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,text]
|
|
----
|
|
<a id="inPageAnchor">Jump down the page to me</a> <!-- Compliant -->
|
|
----
|
|
|