Solved

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

Posted on 2007-03-19
4
265 Views
Last Modified: 2008-02-01
hi all, i asked this question and had it solved, but i didn't realize 1 thing. Here's the question i asked before

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_22436823.html#a18688209

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
0
Comment
Question by:gyra
4 Comments
 
LVL 15

Accepted Solution

by:
stanscott2 earned 250 total points
ID: 18754025
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>

0
 
LVL 30

Assisted Solution

by:third
third earned 250 total points
ID: 18754227
try,

<html>
<head>

<style>

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

</style>

<script>

function ctrlYes() {  
  alert('Ctrl!');
  return false;
}

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

function testCtrl(obj, event) {
    if (document.selection)
       document.selection.empty();
    if (!event) event = window.event;
    if (event.ctrlKey) {      
      obj.style.backgroundColor = obj.style.backgroundColor=='#00008b'?'':'#00008b';
       //ctrlYes();
     }
     else  {
        //ctrlNo();
     }
return false;
}
</script>
</head>
<body>

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

</body>
</html>
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i count words? 2 44
Jquery keyup 4 19
filter portfolio grid display on page load (wordpress) 7 18
Make options hidden and show just option that is on 1 19
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question