# Anchor with onclick

**URL:** https://forum.kirupa.com/t/anchor-with-onclick/290045
**Category:** web dev
**Created:** [June 9, 2009, 2:15am UTC](https://forum.kirupa.com/t/anchor-with-onclick/290045 "2009-06-09T02:15:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)
#### Post date: [June 9, 2009, 2:15am UTC](https://forum.kirupa.com/t/anchor-with-onclick/290045/1 "2009-06-09T02:15:05Z")

</div>

I want two things to happen when someone clicks a hyperlink: 1) automatic scroll to the top of the page. 2) a JS function gets called.

```auto

<a href="#topOfSite" onclick="someFunction()">click here</a>

```

Why is it only going to the top of the site but not calling the function?
