Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Suppress page juming to start

Reply
Thread Tools

Suppress page juming to start

 
 
Emil Horowitz
Guest
Posts: n/a
 
      07-03-2007
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?

Thank you,
Emil


 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      07-03-2007
On Jul 3, 12:36 pm, "Emil Horowitz" <(E-Mail Removed)> wrote:
> 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?


http://www.javascripttoolbox.com/bestpractices/#onclick

Matt Kruse

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      07-03-2007
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
 
Reply With Quote
 
scripts.contact
Guest
Posts: n/a
 
      07-04-2007
On Jul 3, 1:27 pm, ASM <(E-Mail Removed)>
wrote:
> 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;
> }



<button onclick="dothat()">Best</button>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppress validation in a page when a button on a master page is clicked rmp_colo@hotmail.com ASP .Net 1 08-22-2007 07:18 PM
Set Start URL with project Start Page (Visual Studio) Jon Davis ASP .Net 0 11-14-2006 08:23 PM
Suppress ServerValidate on Page? philaphan80@yahoo.com ASP .Net Web Controls 0 10-30-2006 03:13 PM
Suppress ServerValidate on Page? philaphan80@yahoo.com ASP .Net Building Controls 1 10-27-2006 05:23 PM
how can I suppress "enter network password" prompt at start-up/// Jeff Computer Support 1 08-26-2003 10:58 PM



Advertisments