Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is href=javascript:;

Tags:

javascript

in a code which i am goin through there is a link has href=javascript:; in code.when it is clicked it opens a lightbox to show some msg with close button.how is it done.I think this uses dojo

like image 210
vetri02 Avatar asked Apr 28 '10 12:04

vetri02


People also ask

What does href do in Javascript?

Definition and Usage. The href attribute specifies the URL of the page the link goes to.

What is a href used for?

The HTML <a> href Attribute is used to specify the URL of the page that the link goes to. When the href attribute is not present in the <a> an element that it will not be a hyperlink. This attribute is used to specify a link to any address.


2 Answers

The code:

<a href="javascript:;">..</a>

will actually do nothing. Generally this Nothing link allows some javascript code to use the onclick event instead. The onclick event triggers the window which may be from django or jquery or wherever.

like image 160
Russell Avatar answered Oct 26 '22 03:10

Russell


EDITED:

i have just added this link that explane you how dojo work with onlclik event:

  • Dojo, how to do onclick event on a DIV

ok, just for the sake, all the answer here are good answer, in your particular case if you are using Dojo

the <a href="javascript:;" > simply prevent your <a> tag to jump around when clicked and of course have no action!

probably you have something like this in your code:

<a href="javascript:;" id="some" class="some_too" rel="some_too_too">

Dojo simply keep the <a> id OR class OR rel tags and execute the function!

like image 39
Luca Filosofi Avatar answered Oct 26 '22 04:10

Luca Filosofi