# Don't trigger onBeforeUnload when clicking anchor in IE

**URL:** <https://forum.kirupa.com/t/dont-trigger-onbeforeunload-when-clicking-anchor-in-ie/308498>\
**Category:** Uncategorized\
**Created:** [April 24, 2010, 2:30am UTC](https://forum.kirupa.com/t/dont-trigger-onbeforeunload-when-clicking-anchor-in-ie/308498 "2010-04-24T02:30:35Z")\
**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:** [April 24, 2010, 2:30am UTC](https://forum.kirupa.com/t/dont-trigger-onbeforeunload-when-clicking-anchor-in-ie/308498/1 "2010-04-24T02:30:35Z")

</div>

```auto

window.onbeforeunload = function() {
   return 'are you sure you want to leave?';
}
<a href="javascript:void(0)" onclick="someFunction()">button</a>

```

Is there a way to prevent Internet Explorer from triggering the onbeforeunload callback whenever someone clicks on an anchor? I believe that IE thinks that all anchors are used to leave pages. However, my code uses the anchor as a button. If I change my code to…

```auto

<a href="#" onclick="someFunction()">button</a>

```

… onbeforeunload is not called anymore, but it’s bad for my user interface - the page suddenly jumps to the top. I think if I change all my anchor buttons to actual \<button\>s then it would solve the problem, but I really do like how anchors have the default CSS cursor styling…
