PDA

View Full Version : double click hyperlink?


Jason
02-11-2003, 12:54 AM
anyone know how to disable the single click of a hyperlink in Javascript? I have a script to drag the hyperlink on my page and I can't keep it from loading the page for the hyperlink.

thanks,
Jason

JaiL
02-11-2003, 01:38 AM
is the hyperlink in use?
if not, take the address off, so even when the link is clicked, there will be no link....

cortic
02-11-2003, 06:27 AM
you just want the link to do nothing? hmm, I remember reading something like, href=javascript:null but then I also remember it not working lol.
I would generally just target an empty function, but I'd do that cause I'd probably use it (with a browser detection script or something) once I got the drag thing to work.
hope this helps...

post some code, cause its not really clear - could be another way of geting round this.

cg9com
02-11-2003, 06:56 AM
<a href ondbclick="location.href='http://www.codingforums.com/'">Click Here</a>

In blue is the javascript ondbclick ( on double click ) event handler

Mhtml
02-11-2003, 09:39 AM
U is missing the rest of href. I'm not going to try it out but will that keep it as a hyperlink? :confused:

Mhtml
02-11-2003, 09:40 AM
Also isn't that only IE 5.0+?

brothercake
02-11-2003, 09:50 AM
DON'T DO IT - making a link that looks like a link but you can't click on it ... it's a usability nightmare.

I think the real solution to your problem is to define a draggable area where the bit you click on isn't active.

cg9com
02-11-2003, 01:06 PM
it would keep it as a link, but it wouldnt go anywhere
it was just a suggestion seeing as he doesnt want to be able to open the link with one click ....
also, i dont know exactly how new or propietary the double click event handler is ...

brothercake
02-11-2003, 03:32 PM
A link that doesn't go anywhere is not a link ... it's text that looks like a link; it defies the whole point of making your links look different.

If you don't want it to have an HREF, why are you even using a link in the first place? Why not a span?

Jason
02-11-2003, 08:59 PM
I do want the link to work just I want it to work after a double click. Here is an example. I have a Java Script that alows me to drag anything on the screen. If I drag a hyperlink I essentially click on it and the drag becomes worthless. So to activate the link I want a double click method. What is it I need to do for this? And it has to work on Mozilla, Netscape, and IE.

Thanks,
Jason

brothercake
02-11-2003, 09:43 PM
<a ondblclick="document.location='http://www.codingforums.com/'">Coding Forums</a>


Will give you that behaviour, but I still think it's counter-intuitive; it will just confuse people. The real answer is don't have a draggable link - put it in a box.

Jason
02-11-2003, 09:49 PM
thanks, that works...now one more stupid question. If that is a link. Why doesn't it look like one? Is there a way to make it look like a link or am I stuck with plain black text?

Jason

cg9com
02-11-2003, 10:52 PM
brothercake, yours is pretty much the same as mine ...

Jason, href="" makes it a link.

Jason
02-11-2003, 10:57 PM
I know its a link. But it doesn't stand out like a normal link. How can I make a normal user like my grandma realize that if she clicks on the link twice it will go somewhere without having to specify it? Say what is the command to get it to look like its underlined and blue or whatever?

Thanks
Jason

Jason
02-11-2003, 11:21 PM
Thanks everyone who helped, I got what I was needing. It works now with more effects than I wanted but is all good.

Thanks,
Jason

P.S. here is what I used for mine :
<a class="drag" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='blue'" ondblclick="document.location='http://www.codingforums.com/'" Style="text-decoration:underline; color:blue;">CodingForums</a>

cg9com
02-12-2003, 01:20 AM
a quicker way, this will customize all your links, and the hover ...
<style type="text/css">
a {text-decoration:underline;color:blue;}
a:hover {color:red;}
</style>