html - Random behaviour of anchor tags -


i have anchor tag in html used javascript event. code looks this

<a href="#" onclick="myscript()">run</a> 

however, when click script, first time links clicked reloads page. second , subsequent clicks, executes javascript.

my first thought was url

my url is

http://localhost/mypage.php?someid=1234567 

but, after clicking javascript link first time, changes to

http://localhost/mypage.php# 

my solution @ moment change anchor tag span, , mimic behaviour using javascript , css, hacked solution.

why happening? there way prevent this?

my application java struts application, , runs inside frame.

the reason don't stop default action of link, go url #. return false event:

<a href="#" onclick="myscript();return false;">run</a> 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -