Emil Horowitz a écrit :
Hi,
if I wish to just execute JavaScript by clicking on a link, I do not have an
alternativ to entering "#" as the URL. But this makes a scrolled page jump
to its start. As far as I remember there is a command to prevent this and
keep the page where it is, but I cannot remember what it is. Any help?
Ugly way :
<a href="javascript
:dothat();" blah
<a href="javascript
:void();" onclick="dothat();" blah
OK :
<a href="#" onclick="dothat(); return false;" blah
Good :
<a href="page_error.htm" onclick="dothat(); return false;" blah
Better :
<a href="page_error.htm" onclick="return dothat();" blah
Here the function 'dothat()' has to return 'false'
example :
function dothat() {
alert('Hello');
return false;
}
--
Stephane Moriaux et son (moins) vieux Mac