Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you avoid selecting text in <DIV> 1

Status
Not open for further replies.

Boomerang

Programmer
Mar 30, 2001
766
NL
Hi,

In my HTML-file I have a <DIV> that acts like a sort of link (it collapse a block under the link so clicking this &quot;div&quot; will not change a page):

<div onmouseover=&quot;ChangeColor()&quot; onmouseout=&quot;ChangeColorBack()&quot; onclick=&quot;DisplayBlock(1);&quot; style=&quot;cursor:hand; background:#B0E0E6; font-weight:bold; margin-top:4px; width:300px; color:#656565;&quot;>MyDiscription</div>

But if I click on the <div> and then move my mouse, the text &quot;MyDiscription&quot; is selected after a &quot;onmouseup&quot; and stays selected.

How can I avoid this text being selected?

I already changed &quot;onclick&quot; to &quot;onmousedown&quot; but won't solve my problem,

please help,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Put this function in your code somewhere:

Code:
<script>
function SelectStart()
{
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
}
</script>

And make sure your div has this:
Code:
onSelectStart=&quot;SelectStart()&quot;

Let me know if this works or not.
 
Thanx i1 !!!

That's just what I wanted.

Erik

<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top