473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Suppress page juming to start

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
Jul 3 '07 #1
3 1024
On Jul 3, 12:36 pm, "Emil Horowitz" <i...@nexo.dewrote:
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

Jul 3 '07 #2
ASM
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
Jul 3 '07 #3
On Jul 3, 1:27 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
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>

Jul 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andrew Poulos | last post by:
I'm working on an app where the refreshing of the window by pressing the F5 key needs to be suppressed. I thought it would be straightforward but I can't get it to work. This is the code I'm...
0
by: Marshal | last post by:
(This question applies to the AxWebBrowser in .NET 1.x, but 2.0 would be interesting to know about as well) Hi... What's the easiest way to suppress the page header and footers that get printed...
1
by: tertullian | last post by:
I have a page that tries to forward the page using javascript every minute. However, I have to write it so that if the computer were to lose internet connection it would appear to the user as...
7
by: Neil Jarman | last post by:
Hi, I would like to allow users to print a page, but I want to suppress the header and footer that appear by default. I gather its done with a style sheet. Please advise. Many Thanks,
2
by: samir.kuthiala | last post by:
I do some requests in the background on a page using the XMLHttpRequest object. My site uses NTLM Authentication. However if the user is not logged in, it throws up an ugly dialog box. Is there...
1
by: rn5a | last post by:
A custom server control has a Button. Namespace Confirm Public Class ShowConfirm : Inherits Button Private strConfirmMsg As String Public Property ConfirmMessage() As String Get...
0
by: =?Utf-8?B?VG9kZE0=?= | last post by:
I am trying the print an html document using Process.Start with the verb "print", which works except it displays the print dialog box. The printer is set correctly to the one specified using the...
2
by: ZeeHseez | last post by:
Hi, I have written a webbrowser application in VB .net Framework 1.1. I would like to suppress javascript error messages. However, the silent property of the webbrowser control suppresses the...
1
by: Jonas Pedersen | last post by:
hi, I am looking into reusing code to limit number of pages. When ever I display a user's name on the site, It is with a hyperlink so you can view the user profile in a popup window. Is there a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.