Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
30
rated 0 times [  36] [ 6]  / answers: 1 / hits: 70845  / 11 Years ago, tue, july 16, 2013, 12:00:00

I wish to put some instructions with a link - onclick calling a script that display a simple alert box. If I did like this...



<label for=arquivo>Máximo de 1MB, observe os <a href= onclick=ajudaUpload();>tipos permitidos</a>.</label>


the page is reloaded even with a return false, and if I did like this...



<label for=arquivo>Máximo de 1MB, observe os <a href=# onclick=ajudaUpload();>tipos permitidos</a>.</label>


with the # symbol, the page is scrolled to the top and # is added to query string. Is there a third way to do it without reloading, scrolling and garbage?


More From » onclick

 Answers
8

Return false after the call:



<a href= onclick=ajudaUpload();return false;>tipos permitidos</a>


Or if your function returns false then you can return the result of the function:



<a href= onclick=return ajudaUpload();>tipos permitidos</a>


It's not enough to just return false in the function, you need to actually return false from the click handler.


[#76963] Monday, July 15, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
austonjuancarlosb

Total Points: 238
Total Questions: 89
Total Answers: 99

Location: Chad
Member since Mon, Dec 5, 2022
1 Year ago
;