# Make \<a onclick="location.href='this.href';" possible?

**URL:** https://forum.kirupa.com/t/make-a-onclick-location-href-this-href-possible/299069
**Category:** web dev
**Created:** [October 29, 2009, 10:02am UTC](https://forum.kirupa.com/t/make-a-onclick-location-href-this-href-possible/299069 "2009-10-29T10:02:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Env](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@Env](https://forum.kirupa.com/u/Env)
#### Post date: [October 29, 2009, 10:02am UTC](https://forum.kirupa.com/t/make-a-onclick-location-href-this-href-possible/299069/1 "2009-10-29T10:02:37Z")

</div>

Hi guys,

I am having some problems with some ajax and css on a project.

I want to make an anchor link to itself.

\<a href=“[google.com](http://google.com)”\>google\</a\>

I now I can also do this

\<a onclick=“location.href=‘[google.com](http://google.com)’;” href=“[google.com](http://google.com)”\>google\</a\>

But can I make an on click, link to itself? so the onClick will display anything the href displays? I have some ajax on my site that if a button is pressed the href=“[google.com](http://google.com)” becomes something else, but the onclick src does not change…

So could I do this

\<a onclick=“location.href='_this.href’_;” href=“[whateverthisdisplays.com/onclick/willchangetoo](http://whateverthisdisplays.com/onclick/willchangetoo)”\>google.com\</a\>
