What is a Hyperlink that does nothing

C

chill888

I am trying to add behaviours to a transparent image to close a drop
down menu.

To be able to use a mouseover behaviour on the transparent image, I
believe I have to add a hyperlink to the image. I read in a tutorial
that using the hyperlink :

"javascript: ;" -- without the quotes

would allow me to have a link that wouldn't do anything. But when i do
this it give me a link that -- if pressed -- causes the page to become
an error with the web address of "javascript:%20;"
Any advice? Much appreciated and thanks

(e-mail address removed)
 
J

Jon Spivey

Hi,
Lose the space
javascript:;

That's javascript - colon - semicolon with no spaces
 
D

David Berry

You have a space between the word javascript and the semi-colon. Remove the
space so it reads juts javascript;
 
C

chill888

Follow up question (thanks for help on last question)

By changing the hyperlink to javascript:; I have lost my CSS
modification to
a:hover. I had it set to change colors. Is there a tag for this fake
javascript link that I can use for the same effect?
Thanks for patience.
 
D

David Berry

The javascript link shouldn't have affected your CSS styles since it's still
just a hyperlink. It has an href correct? What's the whole line of code
for the link or is there a URL where we can take a look?
 
S

Stefan B Rusynko

Better still for an empty link use javascript:void(0)
<a href="javascript:void(0) onClick="return false;">




| You have a space between the word javascript and the semi-colon. Remove the
| space so it reads juts javascript;
|
| --
| David Berry - MCP
| Microsoft MVP - FrontPage
| FrontPage Support: http://www.net-sites.com/sitebuilder/
| -----------------------------------
| To assist you in getting the best answers for FrontPage support see:
| http://www.net-sites.com/sitebuilder/newsgroups.asp
| -----------------------------------
| | >I am trying to add behaviours to a transparent image to close a drop
| > down menu.
| >
| > To be able to use a mouseover behaviour on the transparent image, I
| > believe I have to add a hyperlink to the image. I read in a tutorial
| > that using the hyperlink :
| >
| > "javascript: ;" -- without the quotes
| >
| > would allow me to have a link that wouldn't do anything. But when i do
| > this it give me a link that -- if pressed -- causes the page to become
| > an error with the web address of "javascript:%20;"
| > Any advice? Much appreciated and thanks
| >
| > (e-mail address removed)
| >
|
|
 
J

Jon Spivey

How's <a href="javascript:void(0)" better than <a href="javascript:;" ? I've
always used the second out of habit but never thought there was anything to
chose between the 2.
 
S

Stefan B Rusynko

My post should have had
<a href="javascript:void(0);" onClick="return false;">

The javascript: protocol evaluates the expression after the colon :)), if there is one, and loads a page containing the string value
of the expression, unless it is undefined. If the expression evaluates to undefined (by calling a void function, for example
javascript:void(0)), no new page loads.

By making it an explicit void you save javascript the trouble of determining it is undefined (and the possible errors of the space
as per the users post)
- the onclick "kills" the click event




| How's <a href="javascript:void(0)" better than <a href="javascript:;" ? I've
| always used the second out of habit but never thought there was anything to
| chose between the 2.
|
| --
| Cheers,
| Jon
| Microsoft MVP
|
| | > Better still for an empty link use javascript:void(0)
| > <a href="javascript:void(0) onClick="return false;">
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | > | You have a space between the word javascript and the semi-colon. Remove
| > the
| > | space so it reads juts javascript;
| > |
| > | --
| > | David Berry - MCP
| > | Microsoft MVP - FrontPage
| > | FrontPage Support: http://www.net-sites.com/sitebuilder/
| > | -----------------------------------
| > | To assist you in getting the best answers for FrontPage support see:
| > | http://www.net-sites.com/sitebuilder/newsgroups.asp
| > | -----------------------------------
| > | | > | >I am trying to add behaviours to a transparent image to close a drop
| > | > down menu.
| > | >
| > | > To be able to use a mouseover behaviour on the transparent image, I
| > | > believe I have to add a hyperlink to the image. I read in a tutorial
| > | > that using the hyperlink :
| > | >
| > | > "javascript: ;" -- without the quotes
| > | >
| > | > would allow me to have a link that wouldn't do anything. But when i
| > do
| > | > this it give me a link that -- if pressed -- causes the page to become
| > | > an error with the web address of "javascript:%20;"
| > | > Any advice? Much appreciated and thanks
| > | >
| > | > (e-mail address removed)
| > | >
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top