Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A HREF and onClick

1 view
Skip to first unread message

Eric C. Chien

unread,
Dec 10, 1996, 3:00:00 AM12/10/96
to

Hi all,

I have found that HREF is mandatory for onClick to work. I've always
included it, as I've never had an occasion when it matter... but now
it does.

I want to use onClick, but not have the page reload at all... just
execute my onClick function.

I've used <A HREF = # > but this reloads the page and < A HREF = "">
try to take me to the directory listing the file is in. Any ideas on
how to make onClick not reload? (like onMouseover).

...Eric
--
===============================================================================
Eric C. Chien http://www.seas.ucla.edu/~ecchien
ecc...@seas.ucla.edu University California Electrical Engineering
ecc...@ucla.edu Los Angeles Microbiology/Molecular Genetics

Arne de Meijere

unread,
Dec 11, 1996, 3:00:00 AM12/11/96
to Eric C. Chien

> I've used <A HREF = # > but this reloads the page and < A HREF = "">
> try to take me to the directory listing the file is in. Any ideas on
> how to make onClick not reload? (like onMouseover).

<a href="javascript:void(0)" onclick=FUNCTION()... (void(0)=do nothing)

or

<a href="javascript:FUNCTION()"...

the first version doesn't work with NN2, for the second solution i don't
know. both work fine with NN3

good luck,
arne

--
Videomuseum
6, rue Beaubourg
75004 Paris
Tel : (33-1) 42.71.61.39
Fax : (33-1) 42.71.62.90
e-mail : mei...@videomuseum.fr

Jeroen Verschuuren

unread,
Dec 11, 1996, 3:00:00 AM12/11/96
to

Eric C. Chien wrote:
>
> Hi all,
>
> I have found that HREF is mandatory for onClick to work. I've always
> included it, as I've never had an occasion when it matter... but now
> it does.
>
> I want to use onClick, but not have the page reload at all... just
> execute my onClick function.
>
> I've used <A HREF = # > but this reloads the page and < A HREF = "">
> try to take me to the directory listing the file is in. Any ideas on
> how to make onClick not reload? (like onMouseover).
>
> ...Eric
> --
> ===============================================================================
> Eric C. Chien http://www.seas.ucla.edu/~ecchien
> ecc...@seas.ucla.edu University California Electrical Engineering
> ecc...@ucla.edu Los Angeles Microbiology/Molecular Genetics

Use HREF="javascript:void('')"

This seams to be an undocumented function in javascript

Jeroen
--
,,,
(o o)
~~~~~oOO~~(_)~~OOo~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ Jeroen Verschuuren ]
[ ]
[ mailto:j.l.m.ve...@utct.ct.utwente.nl ]
[ http://www.ct.utwente.nl/~schuuren ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOO~~( )~~OOo~~~~~~
@ @
/|||\

Arne de Meijere

unread,
Dec 11, 1996, 3:00:00 AM12/11/96
to j.l.m.ve...@ct.utwente.nl

> Use HREF="javascript:void('')"
>
> This seams to be an undocumented function in javascript

no, its in the NN3.0 summary of new features of the netscape autoring
guide....

Cam Chalmers

unread,
Dec 11, 1996, 3:00:00 AM12/11/96
to

Jeroen Verschuuren wrote:
>
> Eric C. Chien wrote:
> >
> > Hi all,
> >
> > I have found that HREF is mandatory for onClick to work. I've always
> > included it, as I've never had an occasion when it matter... but now
> > it does.
> >
> > I want to use onClick, but not have the page reload at all... just
> > execute my onClick function.
> >
> > I've used <A HREF = # > but this reloads the page and < A HREF = "">
> > try to take me to the directory listing the file is in. Any ideas on
> > how to make onClick not reload? (like onMouseover).
> >
> > ...Eric
> > --
> > ===============================================================================
> > Eric C. Chien http://www.seas.ucla.edu/~ecchien
> > ecc...@seas.ucla.edu University California Electrical Engineering
> > ecc...@ucla.edu Los Angeles Microbiology/Molecular Genetics
>
> Use HREF="javascript:void('')"
>
> This seams to be an undocumented function in javascript
>
> Jeroen
> --
> ,,,
> (o o)
> ~~~~~oOO~~(_)~~OOo~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [ Jeroen Verschuuren ]
> [ ]
> [ mailto:j.l.m.ve...@utct.ct.utwente.nl ]
> [ http://www.ct.utwente.nl/~schuuren ]
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOO~~( )~~OOo~~~~~~
> @ @
> /|||\

or use <A HREF="javascript: function()"> without the onClick

--Cam

Michel Bardiaux

unread,
Dec 13, 1996, 3:00:00 AM12/13/96
to

Arne de Meijere wrote:
>
> > Use HREF="javascript:void('')"
> >
> > This seams to be an undocumented function in javascript
>
> no, its in the NN3.0 summary of new features of the netscape autoring
> guide....

And of course doesn't work with MSIE, like most of these new NN3
features. The Netscape pages are actually *proud* of that! Does anyone
know what to use that will work with both NN3 and MSIE3? (I actually
hate Microsnort's guts, but when you make a site for customers...)

Thanks.
--
Michel Bardiaux
UsrConsult S.P.R.L. Rue Margot, 37 B-1457 Nil St Vincent
Tel : +32 10 65.44.15 Fax : +32 10 65.44.10

Nils Juell

unread,
Dec 13, 1996, 3:00:00 AM12/13/96
to

> > > Use HREF="javascript:void('')"

> And of course doesn't work with MSIE, like most of these new NN3


> features. The Netscape pages are actually *proud* of that! Does anyone
> know what to use that will work with both NN3 and MSIE3? (I actually
> hate Microsnort's guts, but when you make a site for customers...)

Make one yourself:

function none(){}

does the exact same thing except you don't have to send any parameters
(like the '' in void)

nhj

Ken Bigelow

unread,
Dec 14, 1996, 3:00:00 AM12/14/96
to

This is exactly what I wound up doing, except that I called it nop() .
--
Ken

Are you interested in |
byte-sized education | http://www.play-hookey.com
over the Internet? |

alexm...@ina.com

unread,
Dec 20, 1996, 3:00:00 AM12/20/96
to

Eric C. Chien wrote:
>
> Hi all,
>
> I have found that HREF is mandatory for onClick to work. I've always
> included it, as I've never had an occasion when it matter... but now
> it does.
>
> I want to use onClick, but not have the page reload at all... just
> execute my onClick function.
>
> I've used <A HREF = # > but this reloads the page and < A HREF = "">
> try to take me to the directory listing the file is in. Any ideas on
> how to make onClick not reload? (like onMouseover).
>
> ...Eric
> --
> ===============================================================================
> Eric C. Chien http://www.seas.ucla.edu/~ecchien
> ecc...@seas.ucla.edu University California Electrical Engineering
> ecc...@ucla.edu Los Angeles Microbiology/Molecular Genetics

given the choice of a user defined function instead of the onclick
event, produces an interesting bug.

<a href="javascript:GoSomewhere('home')" onMouseOver="window.status='Go
home'">Home</A>

When I put the mouse directly over the text anchor Home my status
bar says javascript:GoSomewhere('home')
but if I put my mouse above or below the anchor my status bar
says Go home.

How odd. I wish I could make it say what I want it too.

Uri Postavsky

unread,
Dec 21, 1996, 3:00:00 AM12/21/96
to

Michel Bardiaux wrote:

>
> Arne de Meijere wrote:
> >
> > > Use HREF="javascript:void('')"
> > >
> > > This seams to be an undocumented function in javascript
> >
> > no, its in the NN3.0 summary of new features of the netscape autoring
> > guide....
>
> And of course doesn't work with MSIE, like most of these new NN3
> features. The Netscape pages are actually *proud* of that! Does anyone
> know what to use that will work with both NN3 and MSIE3? (I actually
> hate Microsnort's guts, but when you make a site for customers...)

For NN3 I do this:

<a href="" onClick='myfunc();return false'>

MSIE ignores the "return false" and shows the directory listing, so I
added this:

<a name="here">
<a href="#here" onClick='myfunc();return false'>

MSIE does reload the page, but MSIE users sure deserve this
inconvenience.

I have also added the following code at the beginning of the script, and
I recommend everyone to do something similar:

==========================================================
var MSIE = false;

uAgent = navigator.userAgent;
if (uAgent.indexOf("MSIE", 0)>=0)
MSIE = true;

if (MSIE)
alert("You are using Microsoft Internet Explorer! This site works best
with Netscape Nevigator - download it by following the link on this
page.");


===========================================================

I do this:

<a name="


>
> Thanks.
> --
> Michel Bardiaux
> UsrConsult S.P.R.L. Rue Margot, 37 B-1457 Nil St Vincent
> Tel : +32 10 65.44.15 Fax : +32 10 65.44.10

--
----
Uri Postavsky ur...@rtlsoft.com
Right to Left Software http://www.rtlsoft.com

Paul Johnston

unread,
Dec 21, 1996, 3:00:00 AM12/21/96
to

Hi,

> When I put the mouse directly over the text anchor Home my status
> bar says javascript:GoSomewhere('home')
> but if I put my mouse above or below the anchor my status bar
> says Go home.

Make the onMouseOver event return true. Then Netscape (presumably
version 3 only) will not display the anchor's href.

Works for me :-)

Paul


Brian Jonnes

unread,
Dec 23, 1996, 3:00:00 AM12/23/96
to

In <E27vG...@seas.ucla.edu>, ecc...@mulholland.seas.ucla.edu (Eric C.
Chien) wrote:

Two options:

HREF="#" onclick="functionfoo();return false"><!-- that previous onclick
return cancels the click - but only in N3 ...
OR
HREF="javascript:functionfoo()"><!-- works in all impl of javascript. but
clicking on the link will stop the loading of the current page :-( and
onmouseover wont work in N2 :-(

Cheers,

Brian

0 new messages