Closed Thread Icon

Preserved Topic: javascript protocol ? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18115" title="Pages that link to Preserved Topic: javascript protocol ? (Page 1 of 1)" rel="nofollow" >Preserved Topic: javascript protocol ? <span class="small">(Page 1 of 1)</span>\

 
maestro
Nervous Wreck (II) Inmate

From: Somewhere out there
Insane since: Oct 2001

posted posted 10-16-2001 21:28

Hi, this is my first post in this board. Just wondering if anyone can help me out a little here. Recently while doing some simple javascripts, I came across something which puzzled me.

using html,
<a href="javascript:void(0);" onclick="...">link</a>
and
<a href="javascript://"> onclick="...">link</a>

How does it work, the href="..."? I found out from somewhere that it's javascript protocol but that's about all. Tried using it with href="javascript:void();"... but IE6 detected syntax error... Can someone help to explain all these? Thanks in advance!!



evo.lanche - evolve. the only constant in life.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-16-2001 21:52

instead of using an onClick="some JS here"

the browser makers made it so that links can fire JS events directly. The syntax is
<a href="javascript: myfunction()">
So that you can have a link that just does some Javascript nothing else. However say you want a link that does nothing when clicked, just when moused over?

The old way was this
<a href="#" onmouseover="myfunction()">

the void operator can also be used.
<a href="javacsript: void(0)" onmouseover="myfunction()"> This prevents some problems with clicking on "#" links.



:[ Computers let you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila. ]:

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-16-2001 22:11

The reason void() didn't work is because void isn't a *function*, it's an *operator*, like * or + or "new". It's typically followed by parenthesis to group what it works on. void(0) is the same as void 0. So, to say void() is like saying "3 + "... you're missing the operand.

maestro
Nervous Wreck (II) Inmate

From: Somewhere out there
Insane since: Oct 2001

posted posted 10-17-2001 09:17

hey, thks people. These explanations reallly helped.

Just wondering would adding a semi-colon ";" behind the void(0) be required? or just href="javascript:void(0)" would do? Both IE and NS are able to handle this? How about Opera?

evo.lanche - evolve. the only constant in life.

« BackwardsOnwards »

Show Forum Drop Down Menu