• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Ctrl+click javascript, hightlights text... TNAME...

hi all, i asked this question and had it solved, but i didn't realize 1 thing. Here's the question i asked before


here's the problem. When i ctrl+Click, it briefly highlights the text that i'm clicking on (Selecting it) and then it disappears. I want to stop this behavior. How do i do that? thanx all
2 Solutions
My advice is to NOT use an anchor <a> tag at all.  It's not really a hyperlink, after all.

Instead, use any other HTML element, such as <span>:

<span style="cursor:pointer" onclick="xxxx()">Display text</span>




a#fakeLink  {text-decoration:underline; color:blue; cursor:pointer;}
a#fakeLink:active   {color:ee66dd;}



function ctrlYes() {  
  return false;

function ctrlNo() {  
  alert('No Ctrl!');
  return false;

function testCtrl(obj, event) {
    if (document.selection)
    if (!event) event = window.event;
    if (event.ctrlKey) {      
      obj.style.backgroundColor = obj.style.backgroundColor=='#00008b'?'':'#00008b';
     else  {
return false;

<a id="fakeLink" onClick="testCtrl(this, event);return false;">Click this link</a>

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now