JavaScript onclick

Marketing Glossary

Market Ruler, LLC

JavaScript onclick

In a web page's HTML, a web developer can use JavaScript to trigger client-side code to track when a link is clicked.

The <a> HTML tag appears like so:

<a href="url">Click here to sign up</a>

The onclick attribute can be added to the <a> tag, and the value contains the JavaScript to run when the user:

To add the onclick method:

<a href="url" onclick="return, '8')">Click here to sign up</a>

The onclick attribute should return a value which tells the browser whether to actually load the link or not. If the JavaScript function returns true, then the link will be followed, if it returns false, the link will not be followed.

This allows a program to, for example, put up a warning before following a link.

For more information

Jump to: navigation, search